Azure Template deployment and RGs clean

  1. we can create a VM with a simple template:
    New-AzResourceGroupDeployment -ResourceGroupName myResourceGroup -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json

2. we can try to create our own template file azuredeploy.json:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [
      {
        "type": "Microsoft.Storage/storageAccounts",
        "apiVersion": "2019-04-01",
        "name": "{provide-unique-name}",
        "location": "eastus",
        "sku": {
          "name": "Standard_LRS"
        },
        "kind": "StorageV2",
        "properties": {
          "supportsHttpsTrafficOnly": true
        }
      }
    ]
  }

create resource with commands:

1. create a new ResourceGroup
New-AzResourceGroup `
  -Name myResourceGroup `
  -Location "Central US"

2. addstorage
 $templateFile = "azuredeploy.json"
New-AzResourceGroupDeployment `
  -Name addstorage `
  -ResourceGroupName myResourceGroup `
  -TemplateFile $templateFile

3. you can delete ALL ResourceGroups with command:
Get-AzResourceGroup -Name ‘*’ | Remove-AzResourceGroup -Force -AsJob

Leave a Reply

Your email address will not be published. Required fields are marked *