Skip to content

Instantly share code, notes, and snippets.

😎
Happy Days

Simon Waight sjwaight

😎
Happy Days
Block or report user

Report or block sjwaight

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sjwaight
sjwaight / deploy-thumbnail-k8s.yaml
Created Jun 24, 2019
Deployment file to publish Azure Function app to Kubernetes using KEDA
View deploy-thumbnail-k8s.yaml
data:
AzureWebJobsStorage: XXXXX
FUNCTIONS_WORKER_RUNTIME: XXXX
kedademo01_STORAGE: XXXXX
VIDEOCONTAINER: XXXXX
THUMBNAILCONTAINER: XXXX
VIDEOFILESTORAGE: XXXXX
STORAGE_ACCOUNT_NAME: XXXX
ACCOUNT_ACCESS_KEY: XXXXX
apiVersion: v1
@sjwaight
sjwaight / sample.workflow
Last active Mar 19, 2019
GitHub Action definition to deploy a repository to an Azure Web App
View sample.workflow
workflow "Publish to App Service" {
on = "push"
resolves = ["Deploy to Web App"]
}
action "Azure Login" {
uses = "Azure/github-actions/login@master"
env = {
AZURE_SUBSCRIPTION = "YOUR_AZURE_SUBSCRIPTION_NAME"
}
@sjwaight
sjwaight / createlinuxappservice.sh
Last active Apr 18, 2019
Create a new Python Web App running on App Services running Linux.
View createlinuxappservice.sh
#!/bin/bash
# Based on: https://docs.microsoft.com/en-us/azure/app-service/scripts/cli-linux-docker-aspnetcore#sample-script
# Variables
appName=$1
appPlanName="${appName}plan"
resGroupName=$2
location="WestUS2"
@sjwaight
sjwaight / build-deploy-python-func.yaml
Created Jan 4, 2019
Sample Azure Pipelines Build definition showing how to deploy a Python Function
View build-deploy-python-func.yaml
resources:
- repo: self
queue:
name: Hosted Ubuntu 1604
variables:
FunctionFolder: '**yourfoldername**'
FunctionAppName: '**yourfunctionname**'
steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 2.1.502'
@sjwaight
sjwaight / build-deploy-python-func.sh
Last active Jan 4, 2019
Inline Shell script to build and deploy Azure Functions v2 Python preview apps
View build-deploy-python-func.sh
#
# Build and deploy Python Azure Function v2 (preview) on Azure DevOps
#
# Paste this as an inline script into an "Azure CLI" Build Task running on an Ubuntu 16.04 managed host.
#
# Set Build Variables:
#
# FunctionFolder = name of folder containing your Function
# FunctionAppName = name of the target Azure Function that will receive the deployment.
@sjwaight
sjwaight / migrate-static-web-content.sh
Last active Dec 27, 2018
Bash script to migrate static web site from AWS S3 to Azure Storage Static Websites
View migrate-static-web-content.sh
#!/bin/bash
resourcegroup=$1
demolocation=$2
storageacctname=$3
#####
# Setup AWS
#####
@sjwaight
sjwaight / pass-array-sproc.py
Last active Jul 20, 2019
How to pass an array of items from Python to a Cosmos DB Stored Procedure
View pass-array-sproc.py
import uuid
import os
import azure.cosmos.documents as documents
import azure.cosmos.cosmos_client as cosmos_client
import azure.cosmos.errors as errors
COSMOS_HOST = os.environ['COSMOS_HOST']
MASTER_KEY = os.environ['MASTER_KEY']
DATABASE_ID = os.environ['DATABASE_ID']
@sjwaight
sjwaight / record-tags-in-storage-table.ps1
Created Jun 12, 2018
Shows how you can enumerate Tags on Azure Resource Groups and write them to a Storage Table.
View record-tags-in-storage-table.ps1
Import-Module AzureRmStorageTable
$runDateTime = Get-Date -Format "yyyy-MM-ddTHH\:mm\:ss.fffffffzzz"
$resourceGroup = "STORAGE_RESOURCE_GROUP"
$storageAccount = "STORAGE_ACCOUNT_FOR_TABLE"
$tableName = "STORAGE_ACCOUNT_TABLE_NAME"
# Connect to Storage Account (we assume you have already connected to a Subscription using Login-AzureRmAccount)
$saContext = (Get-AzureRmStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccount).Context
$table = Get-AzureStorageTable -Name $tableName -Context $saContext
@sjwaight
sjwaight / App.xaml.cs
Created May 5, 2018
Updated sample B2C client application configuration
View App.xaml.cs
public partial class App : Application
{
private static string Tenant = "YOUR_TENANT.onmicrosoft.com";
private static string ClientId = "YOUR_API_APPLICATION_ID";
public static string PolicySignUpSignIn = "B2C_1_YOUR_POLICY_susi";
public static string PolicyEditProfile = "B2C_1_YOUR_POLICY_profile";
public static string PolicyResetPassword = "B2C_1_YOUR_POLICY_pwdedit";
public static string[] ApiScopes = { "" };
public static string ApiEndpoint = "https://localhost/demo-api/";
@sjwaight
sjwaight / b2c-custom-demo.cs
Last active Feb 16, 2018
Simple C# code showing how you use Custom Attributes from B2C in a solution.
View b2c-custom-demo.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public void Demo(string userObjectId)
{
/* Lookup the specified user object using object ID
GraphClient can be found at https://github.com/AzureADQuickStarts/B2C-GraphAPI-DotNet */
var graphResponse = await GraphClient.GetUserByObjectId(userObjectId);
var userJson = JObject.Parse(graphResponse);
You can’t perform that action at this time.