Skip to content

Instantly share code, notes, and snippets.

@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-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 / 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 / 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 / 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 / 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",