Skip to content

Instantly share code, notes, and snippets.

@kevinhillinger
kevinhillinger / create_vertex.js
Last active March 22, 2019 15:48
Cosmos DB Stored Procedure - Graph / Gremlin - vertex creation and replacement
// create vertex by label
// both vertex and/or edge should come in as objects. This is inline for clarity of requirements
// the vertex and the edge in this sample demonstrate the minimum required fields and the shape to conform to graph
function create_vertex(label, id) {
var context = getContext();
var collection = context.getCollection();
var selfLink = collection.getSelfLink();
var newVertex = {
@kevinhillinger
kevinhillinger / template.json
Last active November 26, 2020 09:37
Resource Manager (ARM) Template with copyIndex variable to output
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageSettings": {
"type": "object",
"defaultValue": {
"count": 3,
"prefix": "baa"
}
import os, sys, uuid, time
from azure.storage.blob import BlockBlobService, PublicAccess
CONTAINER_NAME = '<container name>'
service = BlockBlobService(account_name='<account name', account_key='<your key>')
try:
service.create_container(container_name = CONTAINER_NAME)
@kevinhillinger
kevinhillinger / new-java-azure-function.bash
Created February 5, 2018 13:46
How to create a new Azure Function for Java using the Maven plugin (MacOS)
#!/bin/bash
# get maven (if you don't already have it
brew update
brew install maven
# get core tools
sudo npm install -g azure-functions-core-tools@core --unsafe-perm true
@kevinhillinger
kevinhillinger / get-apim-access.ps1
Created November 29, 2017 17:19
Get SharedAccessSignature for API Management (v1 REST API) using PowerShell
$Source = @"
namespace Microsoft.Apim
{
using System;
using System.Net;
using System.Text;
using System.Globalization;
using System.Security.Cryptography;
public static class Tools
@kevinhillinger
kevinhillinger / ProcessAzureBlobStorageResultsWithPaging.ps1
Created November 3, 2017 17:52
Using ListBlobsSegmented to page through Azure Blob Storage results
# get the container
$account = Get-AzureRmStorageAccount -Name blobiterationtest0 -ResourceGroupName blob-iteration-test
$context = $account.Context
$container = Get-AzureStorageContainer -Context $context -Name test
$maxResults = 5
$segment = 0 #which segment / result set are we getting? (zero index)
@kevinhillinger
kevinhillinger / create_aci_.py
Last active October 3, 2017 17:11
Azure Container Instance - Create - Python
import os
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.mgmt.containerinstance.models import ContainerGroup
from azure.mgmt.containerinstance.models import IpAddress
subscription_id = os.environ.get(
'AZURE_SUBSCRIPTION_ID',
'11111111-1111-1111-1111-111111111111') # your Azure Subscription Id
@kevinhillinger
kevinhillinger / self_delete_aci.py
Created October 3, 2017 16:55
Azure Container Instance - Self Deletion - Python
import os
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
subscription_id = os.environ.get(
'AZURE_SUBSCRIPTION_ID',
'11111111-1111-1111-1111-111111111111') # your Azure Subscription Id
credentials = ServicePrincipalCredentials(
client_id=os.environ['AZURE_CLIENT_ID'],
@kevinhillinger
kevinhillinger / AzureSettings.cs
Last active September 28, 2017 15:38
Lookup FQDN of Application Gateway for backend App Services Web App - asp.net core
public class AzureSettings
{
public IAzure Azure { get; set; }
}
@kevinhillinger
kevinhillinger / provision_vm.ps1
Created August 9, 2017 18:39
Provision VM from existing OS disk and data disks
function New-ProvisionVirtualMachineCommand() {
$command = (New-Object -TypeName PSObject -Prop (@{
Name = $null;
Size = $null;
DnsLabel = $null;
Location = $null;
Credentials = $null
ResourceGroup = @{ Name = $null; Location = $null };
VirtualNetwork = @{ Name = $null; ResourceGroupName = $null; Location = $null; SubnetName = $null; };
OS = @{ Windows = $true; Linux = $false };