Skip to content

Instantly share code, notes, and snippets.

View andrew-kelleher's full-sized avatar

Andrew Kelleher andrew-kelleher

View GitHub Profile
@andrew-kelleher
andrew-kelleher / run.ps1
Last active April 23, 2024 12:20
Azure Function App PowerShell script to backup Blob storage to an Azure File share
# Input bindings are passed in via param block.
param($Timer)
# Define variables
$SrcStgAccURI = "https://sourceblobstg.blob.core.windows.net/"
$SrcBlobContainer = "myblobs"
$SrcSASToken = SAS_TOKEN_SOURCE
$SrcFullPath = "$($SrcStgAccURI)$($SrcBlobContainer)?$($SrcSASToken)"
$DstStgAccURI = "https://destinationfilestg.file.core.windows.net/"
@andrew-kelleher
andrew-kelleher / azuredeploy_withscriptactions.json
Created November 6, 2019 15:59
Example Azure HDInsight ARM template with script actions
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"type": "string",
"metadata": {
"description": "The name of the HDInsight cluster to create."
}
},
@andrew-kelleher
andrew-kelleher / azuredeploy_noscriptactions.json
Created November 6, 2019 15:51
Example Azure HDInsight ARM template
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusterName": {
"type": "string",
"metadata": {
"description": "The name of the HDInsight cluster to create."
}
},
@andrew-kelleher
andrew-kelleher / apimappgw.ps1
Created May 8, 2019 12:33
Extract from PowerShell script showing how Azure App Gateway path-based routing rules can used to protect internal API's on API Management
# Get existing Application Gateway config
$appgw = Get-AzApplicationGateway -ResourceGroupName $resGroupName -Name $appgwName
$listener = Get-AzApplicationGatewayHttpListener -Name "apim-gw-listener01" -ApplicationGateway $appgw
$sinkpool = Get-AzApplicationGatewayBackendAddressPool -ApplicationGateway $appgw -Name "sinkpool"
$pool = Get-AzApplicationGatewayBackendAddressPool -ApplicationGateway $appgw -Name "apimbackend"
$poolSettings = Get-AzApplicationGatewayBackendHttpSettings -ApplicationGateway $appgw -Name "apim-gw-poolsetting"
# Add external path rule + map
$pathRule = New-AzApplicationGatewayPathRuleConfig -Name "external" -Paths "/external/*" -BackendAddressPool $pool -BackendHttpSettings $poolSettings
$appgw = Add-AzApplicationGatewayUrlPathMapConfig -ApplicationGateway $appgw -Name "external-urlpathmapconfig" -PathRules $pathRule -DefaultBackendAddressPool $sinkpool -DefaultBackendHttpSettings $poolSettings
@andrew-kelleher
andrew-kelleher / AzurePolicyExample2.ps1
Created November 12, 2018 12:29
Azure Policy Example - full example using resource ID's passed as parameters to New-AzureRmPolicyAssignment cmdlet
# Example script to using the -scope and notscope parameters for the New-AzureRmPolicyAssignment cmdlet
# script applies a policy subscription wide but also excludes specific resource groups
# Login to Azure
Connect-AzureRmAccount
# Get the subscription to assign the policy to
$subscription = Get-AzureRmSubscription -SubscriptionName "subscriptioname"
Write-Host $subscription.Id
@andrew-kelleher
andrew-kelleher / AzurePolicyExample1.ps1
Created November 12, 2018 12:02
Azure Policy Example - example using New-AzureRmPolicyAssignment cmdlet
New-AzureRmPolicyAssignment -Name 'Audit secure transfer to storage accounts' -PolicyDefinition $Policy -Scope $subscription -NotScope $resourceGroup
@andrew-kelleher
andrew-kelleher / S2SVPNERCoexistence.ps1
Last active August 30, 2018 11:55
PowerShell script to deploy Azure ExpressRoute gateway and S2S VPN gateway in correct order for coexistence
# Log into Azure
Connect-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName 'yoursubscription'
# Create a new resource group to host our network resources
$location = "West Europe"
$resourcegroup = New-AzureRmResourceGroup -Name "network-rg" -Location $location
# Create a new VNet
$virtualnetwork = New-AzureRmVirtualNetwork -Name "test-we-vnet" -ResourceGroupName $resourcegroup.ResourceGroupName -Location $location -AddressPrefix "10.10.0.0/16"