Skip to content

Instantly share code, notes, and snippets.

@bmoore-msft
bmoore-msft / createUiDefinition-existing-subnet.json
Created May 24, 2022 20:51
Sample createUiDefinition.json file that shows how to provide an experience to select an existing subnet
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "vnetSelector",
"type": "Microsoft.Solutions.ResourceSelector",
"label": "Virtual Network",
@bmoore-msft
bmoore-msft / main.json
Last active August 31, 2021 17:32
ARM Template using MSI for custom script extension download
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.451.19169",
"templateHash": "16656980055364544710"
}
},
@bmoore-msft
bmoore-msft / gist:09c395015e9486c75ddb2f45dc5028b0
Created July 30, 2021 23:04
deploy a resource with an expression for the type property
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"type": {
"type": "string",
"defaultValue": "Microsoft.Network/publicIPAddresses"
}
},
"resources": [
@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
#>
@bmoore-msft
bmoore-msft / Get-ProviderApiVersion.psm1
Last active January 14, 2021 16:09
Get the api versions and locations for a resource type published in the manifest
function api {
<#
.Synopsis
Get the api versions and locations for a resource type.
.Description
Lists all the available api versions and locations for a given resource type. Information is pulled from the /providers api
which returns the information in the manifest published to ARM.
.Notes
The resource parameter requires the format of Namespace/type, e.g. Microsoft.Storage/storageAccounts
> api Microsoft.Storage/storageAccounts
@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 / 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.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 / 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 / Verify-DeploymentGuid.ps1
Last active March 22, 2022 19:20
Fetch the resources tagged in a pid-[GUID] deployment
Param(
[string][Parameter(Mandatory=$true)]$deploymentName, # the full name of the deployment, e.g. pid-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
[string][Parameter(Mandatory=$true)]$resourceGroupName
)
# Get the correlationId of the named deployment
$correlationId = (Get-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name "$deploymentName").correlationId
# Find all deployments with that correlationId
$deployments = Get-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName | Where-Object{$_.correlationId -eq $correlationId}