Skip to content

Instantly share code, notes, and snippets.

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
@bmoore-msft
bmoore-msft / variableNicConfigs.json
Created June 13, 2017 15:32
Deploys 2 NICs in a copyLoop with different ipConfigurations
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"nicIPConfigurations": [
{
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', 'vNet', 'Subnet-1')]"
@bmoore-msft
bmoore-msft / azuredeploy.json
Created June 27, 2017 16:16
AzureRM deployment template using listKeys on a storageAccount
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"storeName": "[concat('store', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storeName')]",
#
#This script will call the validateMoveResources api to see if resources can be moved (before you try to actually move them)
#
$subscriptionId = '...'
$sourceResourceGroup = 'SourceGroup'
$destinationResourceGroup = 'DestGroup' #must exist
# Create an array of resourceIds that are to be moved
$resourcesToMove = @(
"/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup/providers/Microsoft.Network/publicIPAddresses/somePublicIp"
@bmoore-msft
bmoore-msft / copy-md-blob.ps1
Created August 27, 2018 18:44
Copies the blob from a managed disk export to another storage account and creates a sasToken for marketplace publishing
param
(
[string]$sourceBlobUri,
[String]$StorageAccountName,
[string]$StorageAccountResourceGroupLocation,
[String]$StorageContainerName = 'vhds',
[String]$BlobName = 'marketplace.vhd'
)
#get Dest Storage context
@bmoore-msft
bmoore-msft / New-CertificateInKeyVault
Created May 25, 2018 23:05
Create a new cert, base64 encode it and put it in KeyVault
#Requires -Module AzureRM.KeyVault
# Use this script to create a certificate that you can use to secure a Service Fabric Cluster or other VM/SSL scenario
# This script requires an existing KeyVault that is EnabledFor[Template]Deployment (property depends on the scenario)
# To create a new vault and set the EnabledForDeployment/EnabledForTemplateDeployment property run:
#
# New-AzureRmResourceGroup -Name KeyVaults -Location WestUS
# New-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName KeyVaults -Location WestUS -EnabledForDeployment -EnabledForTempalteDeployment
#
# Once the certificate is created and stored in the vault, the script will provide the parameter values needed for template deployment
@bmoore-msft
bmoore-msft / Get-DeploymentCount.ps1
Created May 3, 2019 18:00
Get the count of deployments in each resource group in each subscription
# use this script to get all the deployments in all subscriptions the current user context has access to - it can
# be useful to find groups that are close to the 800 limit
param(
[int]$deploymentCountWarningLevel = 700 # number of deployments where a warning should be written
)
Disable-AzContextAutosave -Verbose
$subs = Get-AzSubscription
@bmoore-msft
bmoore-msft / remove-deployments-jobs.ps1
Last active September 16, 2019 19:12
Delete Deployments from a ResourceGroup Using Jobs and a Service Principal
#
#this script will delete deployments from a resourceGroup if the number of deployments exceeds the number specified by the Max parameter
#
Param(
[string] [Parameter(Mandatory = $true)] $ResourceGroupName,
[int] [Parameter(Mandatory = $true)] $Max,
[string] [Parameter(Mandatory = $true)] $tenantId,
[string] [Parameter(Mandatory = $true)] $ServicePrincipalId,
[securestring] [Parameter(Mandatory = $true)] $ServicePrincipalSecret,
@bmoore-msft
bmoore-msft / remove-deployments.ps1
Created February 6, 2019 18:42
Delete Deployments from a ResourceGroup Based on a Max Number
#
#this script will delete deployments from a resourceGroup if the number of deployments exceeds the number specified by the Max parameter
#
Param(
[string] [Parameter(Mandatory=$true)] $ResourceGroupName,
[int] [Parameter(Mandatory=$true)] $Max
)
$deployments = Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName
@bmoore-msft
bmoore-msft / Invoke-RESTDeployment.ps1
Last active July 16, 2020 19:13
Deploy a template using a REST command from the az cli
<#
.Synopsis
This script will deploy an Azure Resource Manager Template using the "az rest" command to invoke the REST api directly
.Description
This script will deploy an Azure Resource Manager Template using the "az rest" command to invoke the REST api directly.
It deploys at resourceGroup scope but can be easily modified for any scope of deployment.
The current account context must already be selected before executing the script, use 'az account show' to show the context
#>