Skip to content

Instantly share code, notes, and snippets.

View jjgriff93's full-sized avatar

James Griffin jjgriff93

  • AI Incubator @ Tony Blair Institute for Global Change
  • UK
View GitHub Profile
@jjgriff93
jjgriff93 / gist:cc6d3f8a383396f89583c6f960de1c45
Last active April 1, 2020 14:51
Terraform bug - Error destroying App Service Plan when switching Azure Functions from Basic/Standard/Premium to Dynamic
azurerm_resource_group.rg: Refreshing state... [id=/subscriptions/b9ea69a5-4c3f-49e1-9fea-30145415316f/resourceGroups/myTFResourceGroup]
azurerm_app_service_plan.trafficdata: Refreshing state... [id=/subscriptions/b9ea69a5-4c3f-49e1-9fea-30145415316f/resourceGroups/myTFResourceGroup/providers/Microsoft.Web/serverfarms/myTrafficFunctionPlan]
azurerm_function_app.trafficdata: Refreshing state... [id=/subscriptions/b9ea69a5-4c3f-49e1-9fea-30145415316f/resourceGroups/myTFResourceGroup/providers/Microsoft.Web/sites/myTrafficFinction]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
-/+ destroy and then create replacement
Terraform will perform the following actions:
@jjgriff93
jjgriff93 / gist:94b0b6c652682a8adc4527c590c95f34
Created March 3, 2020 16:31
Terraform bug - sporadic changes to function app settings on redeploy
Terraform will perform the following actions:
module.functions.azurerm_function_app.trafficdata will be updated in-place ~ resource "azurerm_function_app" "trafficdata" { app_service_plan_id = "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/rg-xxxxxxx-test-traffic/providers/Microsoft.Web/serverfarms/plan-xxxxxxxxxx-traffic-test" ~ app_settings = { "APPINSIGHTS_INSTRUMENTATIONKEY" = "xxxxxxxxxxxxxxxxxxxxxxxxxxx" "AZURE_MAPS_ENDPOINT" = "https://atlas.microsoft.com/"
"BUILD_FLAGS" = "UseExpressBuild" -> null "CITIES_CONFIG_URL" = "https://xxxxxxxxxxxxxxxxx.blob.core.windows.net/config/cities.json"
"ENABLE_ORYX_BUILD" = "true" -> null "FUNCTIONS_WORKER_RUNTIME" = "python" "KEY_VAULT" = "https://xxxxxxxxxxxxxxxx.vault.azure.net/" "NUM_OF_ROUTES_PER_CITY" = "100"
"SCM_DO_BUILD_DURING_DEPLOYMENT" = "1"
@jjgriff93
jjgriff93 / gist:5836c4a6ea2c4fea69e7cc223b003771
Created March 3, 2020 15:58
Terraform output: app_service_plan redeploy bug
module.functions.azurerm_app_service_plan.trafficdata must be replaced-/+ resource "azurerm_app_service_plan" "trafficdata" { + app_service_environment_id = (known after apply) ~ id = "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/rg-boltteal-test-traffic/providers/Microsoft.Web/serverfarms/plan-boltteal-traffic-test" -> (known after apply)
is_xenon = false -> null ~ kind = "linux" -> "functionapp" # forces replacement
@jjgriff93
jjgriff93 / Stripe-AddNewSubscription.cs
Created March 5, 2018 20:00
Stripe API - add new product subscriptions
//Register user for Product Plan in Stripe
StripeConfiguration.SetApiKey(StripeAPIKey);
var items = new List<StripeSubscriptionItemOption> {
//Subscribe to Stripe plan with corresponding ID - ENSURE YOUR STRIPE PRICING PLAN ID IS IDENTICAL TO THE APIM PRODUCT ID
new StripeSubscriptionItemOption {PlanId = Request.QueryString["productId"]}
};
var options = new StripeSubscriptionCreateOptions
{
Items = items,
@jjgriff93
jjgriff93 / Stripe-AddNewCustomer.cs
Created March 5, 2018 18:14
Stripe API - add new customer
// Create the user in Stripe using the Stripe API
StripeConfiguration.SetApiKey(StripeAPIKey);
var options = new StripeCustomerCreateOptions
{
//Add the customer's email address to Stripe
Email = model.Email,
};
var service = new StripeCustomerService();
//Returns us a customer object with a unique Stripe ID for them
StripeCustomer customer = service.Create(options);
@jjgriff93
jjgriff93 / GetCarImage.cs
Created February 27, 2018 13:32
C# HTTP Trigger Azure function code to get requested image from blob storage and optionally resize it based on request body parameters
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using Newtonsoft.Json;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Drawing;
@jjgriff93
jjgriff93 / program.cs
Last active February 4, 2018 06:46
Azure .NET Mgmt API - program.cs with vm and storage creation methods
using System;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;
namespace FluentAPIApp
{
class Program
{
public static void Main(string[] args)
@jjgriff93
jjgriff93 / program.cs
Last active February 4, 2018 01:38
Azure .NET mgmt API - program.cs to create VM
using System;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;
namespace FluentAPIApp
{
class Program
{
static void Main(string[] args)
@jjgriff93
jjgriff93 / program.cs
Last active February 4, 2018 01:39
Azure .NET mgmt API - basic program.cs
using System;
using System.Collections.Generic;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;
namespace FluentAPIApp
{
class Program
{
@jjgriff93
jjgriff93 / programcsusing.cs
Last active February 4, 2018 06:36
Azure .NET mgmt API - program.cs using
using System.Collections.Generic;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;