Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Happy Days

Simon Waight sjwaight

😎
Happy Days
View GitHub Profile
@sjwaight
sjwaight / iobindingfunction.py
Last active Oct 28, 2020
Python Azure Function sample showing how to using Input and Output binding with Azure Blob Storage and doing local file manipulation.
View iobindingfunction.py
from io import BytesIO
from logging import FileHandler
import logging
import azure.functions as func
from PIL import Image
def main(msg: func.QueueMessage, inputblob: func.InputStream,
outputblob: func.Out[func.InputStream]) -> None:
blob_source_raw_name = msg.get_body().decode('utf-8')
@sjwaight
sjwaight / function.json
Created Oct 28, 2020
Sample Azure Functions config file for a Python Function with an Input and Output Binding
View function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "msg",
"type": "queueTrigger",
"direction": "in",
"queueName": "images",
"connection": "customserverless01_STORAGE"
},
@sjwaight
sjwaight / JpegUploadRouter.cs
Created Oct 28, 2020
Simple C# Azure Function show Trigger and Output Binding
View JpegUploadRouter.cs
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 Feb 18, 2020
Download Azure IP ranges and Service Tags (Feb 2020)
View Get-AzureIPRangeFile.ps1
$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 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
#####
You can’t perform that action at this time.