Skip to content

Instantly share code, notes, and snippets.

View sjwaight's full-sized avatar
😎
Happy Days

Simon Waight sjwaight

😎
Happy Days
View GitHub Profile
@sjwaight
sjwaight / function.json
Created October 28, 2020 23:25
Sample Azure Functions config file for a Python Function with an Input and Output Binding
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "msg",
"type": "queueTrigger",
"direction": "in",
"queueName": "images",
"connection": "customserverless01_STORAGE"
},
@sjwaight
sjwaight / JpegUploadRouter.cs
Created October 28, 2020 22:30
Simple C# Azure Function show Trigger and Output Binding
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Blob;
namespace Siliconvalve.Demo
{
public static class JpegUploadRouter
@sjwaight
sjwaight / Get-AzureIPRangeFile.ps1
Last active February 18, 2020 05:43
Download Azure IP ranges and Service Tags (Feb 2020)
$fileDate = Get-Date -Format "yyyy-MM-dd-HH-mm"
$urlDownload = (Invoke-WebRequest https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519 -UseBasicParsing).Links | Where-Object {$_.href -Match "ServiceTags"} | Select-Object -Property href -First 1
Invoke-WebRequest $urlDownload.href -OutFile "$fileDate.json"
@sjwaight
sjwaight / deploy-thumbnail-k8s.yaml
Created June 24, 2019 08:44
Deployment file to publish Azure Function app to Kubernetes using KEDA
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 March 19, 2019 01:33
GitHub Action definition to deploy a repository to an Azure Web App
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 April 18, 2019 04:49
Create a new Python Web App running on App Services running Linux.
#!/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 January 4, 2019 06:14
Sample Azure Pipelines Build definition showing how to deploy a Python Function
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 January 4, 2019 05:38
Inline Shell script to build and deploy Azure Functions v2 Python preview apps
#
# 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 December 27, 2018 01:22
Bash script to migrate static web site from AWS S3 to Azure Storage Static Websites
#!/bin/bash
resourcegroup=$1
demolocation=$2
storageacctname=$3
#####
# Setup AWS
#####
@sjwaight
sjwaight / pass-array-sproc.py
Last active October 27, 2020 16:17
How to pass an array of items from Python to a Cosmos DB Stored Procedure (v3 Python SDK or earlier).
import uuid
import os
# v3 Python SDK - note that v4 changed the API and stored procedures now live in the azure.cosmos.scripts module.
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']