Skip to content

Instantly share code, notes, and snippets.

@bcnzer
bcnzer / proxies.json
Created August 6, 2018 09:17
Azure Function proxy with response header
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"PingProxy": {
"matchCondition": {
"route": "/api/v1/{*restOfPath}"
},
"backendUri": "https://localhost/api/{restOfPath}",
"responseOverrides": {
"response.headers.spl-version": "2018-03-08"
@bcnzer
bcnzer / web.config
Last active January 2, 2023 16:28
Web.config for use with a Vue.js SPA (single page app) and woff font files
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<mimeMap fileExtension="woff2" mimeType="application/font-woff" />
</staticContent>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
@bcnzer
bcnzer / postman-pre-request.js
Last active May 14, 2024 08:23
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@bcnzer
bcnzer / local.settings.json
Last active December 19, 2017 19:04
The local.setting.json file from my Azure Function app, which contains application setting info
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<connection string to blob storage>",
"AzureWebJobsDashboard": "",
"WolfImageContainer": "wolfpictures-originals",
"WolfImageQueue": "queue-wolfimages",
"Auth0Audience": "<auth0 key>",
"Auth0Issuer": "https://wolftracker.au.auth0.com/",
"CognitiveServicesVisionUrl": "https://southcentralus.api.cognitive.microsoft.com/vision/v1.0/",
@bcnzer
bcnzer / PingTimer.cs
Created December 18, 2017 19:55
Example C# Azure Function timer function
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace WolfTrackerAPI
{
public static class PingTimer
{
@bcnzer
bcnzer / FixContentTypes.ps1
Created December 18, 2017 09:37
Script I use to fix the content types.
# Note that variables. You can just replace them with text in quotes. For the WolfTrackerBlobKey I would suggest pulling
# that data from Azure Key Vault
$Context = New-AzureStorageContext -StorageAccountName $(BlobServiceName) -StorageAccountKey $(WolfTrackerBlobKey)
$Blobs = Get-AzureStorageBlob -Context $Context -Container $(WolfTrackerBlobContainer)
foreach ($Blob in $Blobs)
{
$Extn = [IO.Path]::GetExtension($Blob.Name)
$ContentType = ""
@bcnzer
bcnzer / DeleteContentFromBlobStorage.ps1
Created December 18, 2017 09:28
Deleted all content from an Azure Storage blob container
# You will either need variables created for WolfTrackerBlobKey or just put the text there in quotes. Ditto with BlobServiceName and
# WolfTrackerBlobContainer. I would suggest you store WolfTrackerBlobKey in Azure Key Vault and pull it from there
$Context = New-AzureStorageContext -StorageAccountName $(BlobServiceName) -StorageAccountKey $(WolfTrackerBlobKey)
$blobs = Get-AzureStorageBlob -Context $Context -Container $(WolfTrackerBlobContainer)
foreach ($blob in $blobs)
{
Write-Host ("Removing Blob: {0}" -f $blob.Name)
Remove-AzureStorageBlob -ICloudBlob $blob.ICloudBlob -Context $Context
@bcnzer
bcnzer / mockwolfimages.json
Created December 17, 2017 19:00
The mock wolf image JSON
{
"wolves": [
{ "images": [
"https://wolftracker9eee.blob.core.windows.net/wolfpictures-mock/big-wolf1.png",
"https://wolftracker9eee.blob.core.windows.net/wolfpictures-mock/wolf1.png"
]},
{ "images": [
"https://wolftracker9eee.blob.core.windows.net/wolfpictures-mock/big-wolf2.png",
"https://wolftracker9eee.blob.core.windows.net/wolfpictures-mock/wolf2.png"
]},
@bcnzer
bcnzer / login.html
Created December 17, 2017 18:40
Auth0 customized login page HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sign In with Wolf Tracker</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
@bcnzer
bcnzer / SetContentType.ps1
Created November 27, 2017 18:52
Iterates through a collection of blobs in a container and fixes/sets the Content Type for types that AzCopy /SetContentType either misses or messes up
# The File Copy step (which uses AzCopy) has /SetContentType but it ignores a bunch of types and messes
# up the content type of others. This script fixes the common ones.
$StorageAccountName = "<ENTER YOUR STORAGE ACCOUNT NAME HERE>" # i.e. WolfTrackerStorage
# If you're using VSTS I would strongly suggest using Key Vault to store and retrieve the key. Keep secrets out of your code!
$StorageAccountKey = "<ENTER YOUR STORAGE KEY FROM THE PORTAL>"
$ContainerName = "<NAME OF THE BLOB CONTAINER>" # i.e. wolfpics
$Context = New-AzureStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
$Blobs = Get-AzureStorageBlob -Context $Context -Container $ContainerName