Related
I have an Azure Resource Group Deployment project in Visual Studio 2019 that validates and deploys fine from Visual Studio, however when I try to deploy it through Azure Release Pipeline with an Azure Resource Group Deployment Task it intermittently fails with the error:
The request content was invalid and could not be deserialized:
'Required property 'type' not found in JSON. Path
'properties.template.resources[6]', line 1, position 3759.'. Task
failed while creating or updating the template deployment.
I haven't been able to find any helpful information in my research of the problem.
Here is the template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sql_name": {
"defaultValue": "project-sql",
"type": "String"
},
"name": {
"defaultValue": "a-data-factory",
"type": "String"
},
"location": {
"defaultValue": "Central US",
"type": "String"
},
"apiVersion": {
"defaultValue": "2018-06-01",
"type": "String"
},
"gitAccountName": {
"type": "String"
},
"gitRepositoryName": {
"type": "String"
},
"gitBranchName": {
"defaultValue": "foo-branch",
"type": "String"
},
"gitRootFolder": {
"defaultValue": "/",
"type": "String"
},
"gitProjectName": {
"type": "String"
},
"ssisdbname": {
"type": "String",
"defaultValue": "SSISDB"
},
"factoryName": {
"type": "string",
"metadata": "Data Factory Name",
"defaultValue": "a-data-factory"
}
},
"variables": {
"factoryId": "[concat('Microsoft.DataFactory/factories/', parameters('factoryName'))]"
},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2015-05-01-preview",
"name": "[parameters('sql_name')]",
"location": "northcentralus",
"kind": "v12.0",
"properties": {
"administratorLogin": "theadmin",
"administratorLoginPassword": "",
"version": "12.0"
}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2017-03-01-preview",
"name": "[concat(parameters('sql_name'), '/dummyDB')]",
"location": "northcentralus",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sql_name'))]"
],
"sku": {
"name": "S0",
"tier": "Standard"
},
"kind": "v12.0,user",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": 268435456000,
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"zoneRedundant": false
}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2017-03-01-preview",
"name": "[concat(parameters('sql_name'), '/dummerDB')]",
"location": "northcentralus",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sql_name'))]"
],
"sku": {
"name": "S0",
"tier": "Standard"
},
"kind": "v12.0,user",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": 268435456000,
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"zoneRedundant": false
}
},
{
"type": "Microsoft.Sql/servers/encryptionProtector",
"apiVersion": "2015-05-01-preview",
"name": "[concat(parameters('sql_name'), '/current')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sql_name'))]"
],
"kind": "servicemanaged",
"properties": {
"serverKeyName": "ServiceManaged",
"serverKeyType": "ServiceManaged"
}
},
{
"type": "Microsoft.Sql/servers/firewallRules",
"apiVersion": "2015-05-01-preview",
"name": "[concat(parameters('sql_name'), '/AllowAllWindowsAzureIps')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sql_name'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
}
},
{
"type": "Microsoft.DataFactory/factories",
"apiVersion": "[parameters('apiVersion')]",
"name": "[parameters('factoryName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"resources": [
{
"name": "[concat(parameters('factoryName'), '/theIntegrationRuntime1')]",
"type": "Microsoft.DataFactory/factories/integrationRuntimes",
"apiVersion": "2018-06-01",
"properties": {
"type": "Managed",
"typeProperties": {
"computeProperties": {
"location": "Central US",
"nodeSize": "Standard_D2_v3",
"numberOfNodes": 1,
"maxParallelExecutionsPerNode": 2
},
"ssisProperties": {
"catalogInfo": {
"catalogServerEndpoint": "project-sql.database.windows.net",
"catalogAdminUserName": "theadmin",
"catalogAdminPassword": {
"type": "SecureString",
"value": ""
},
"catalogPricingTier": "S0"
},
"edition": "Standard",
"licenseType": "LicenseIncluded"
}
}
},
"dependsOn": [ "[resourceId('Microsoft.DataFactory/factories', parameters('factoryname'))]" ]
}
],
"properties": {
"repoConfiguration": {
"type": "FactoryVSTSConfiguration",
"accountName": "[parameters('gitAccountName')]",
"repositoryName": "[parameters('gitRepositoryName')]",
"collaborationBranch": "[parameters('gitBranchName')]",
"rootFolder": "[parameters('gitRootFolder')]",
"projectName": "[parameters('gitProjectName')]"
}
},
"dependsOn": [ "[resourceId('Microsoft.Sql/servers', parameters('sql_name'))]" ]
}
]
}
The Release Pipeline was pointed to an old build artifact with a malformed template.
I am looking for a way to onboard already existing Azure windows VMs by adding VM extension with McAfee paid agent using "ARM templates". I am unable to find the proper way to do it .
Here a default quick start template for adding a VM with McAfee trial version, You can utilize this to do the further processing
Template file
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"newStorageAccountName": {
"type": "string",
"metadata": {
"description": "Storage Account Name"
}
},
"publicIPAddressName": {
"type": "string",
"metadata": {
"description": "Public IP Address Name"
}
},
"publicIPAddressType": {
"type": "string",
"defaultValue": "Dynamic",
"allowedValues": [
"Dynamic"
],
"metadata": {
"description": "Public IP Address Type"
}
},
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_D3",
"metadata": {
"description": "Size of the VM"
}
},
"imagePublisher": {
"type": "string",
"defaultValue": "MicrosoftWindowsServer",
"metadata": {
"description": "Image Publisher"
}
},
"imageOffer": {
"type": "string",
"defaultValue": "WindowsServer",
"metadata": {
"description": "Image Offer"
}
},
"imageSKU": {
"type": "string",
"defaultValue": "2012-R2-Datacenter",
"metadata": {
"description": "Image SKU"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Admin username"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Admin password"
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "VNET Name"
}
},
"addressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/16",
"metadata": {
"description": "VNET address space"
}
},
"subnet1Name": {
"type": "string",
"defaultValue": "Subnet-1",
"metadata": {
"description": "Subnet 1 name"
}
},
"subnet1Prefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
"metadata": {
"description": "Subnet 1 address space"
}
},
"nicName": {
"type": "string",
"metadata": {
"description": "Name of the NIC"
}
},
"vmExtensionName": {
"type": "string",
"metadata": {
"description": "Extension name"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/',parameters('subnet1Name'))]",
"storageAccountType": "Standard_LRS"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('newStorageAccountName')]",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddressName')]",
"location": "[parameters('location')]",
"properties": {
"publicIPAllocationMethod": "[parameters('publicIPAddressType')]"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"subnets": [
{
"name": "[parameters('subnet1Name')]",
"properties": {
"addressPrefix": "[parameters('subnet1Prefix')]"
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('nicName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('imagePublisher')]",
"offer": "[parameters('imageOffer')]",
"sku": "[parameters('imageSKU')]",
"version": "latest"
},
"osDisk": {
"name": "[concat(parameters('vmName'),'_OSDisk')]",
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',parameters('nicName'))]"
}
]
}
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('vmName'),'/', parameters('vmExtensionName'))]",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]"
],
"properties": {
"publisher": "McAfee.EndpointSecurity",
"type": "McAfeeEndpointSecurity",
"typeHandlerVersion": "6.0",
"settings": {
"featureVS": "true",
"featureBP": "true",
"featureFW": "true",
"relayServer": "false"
},
"protectedSettings": null
}
}
]
}
You will be able to see the VM extension node in the bottom of the template.
Also please find the param list for the same.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"newStorageAccountName": {
"value": "GEN-UNIQUE-8"
},
"publicIPAddressName": {
"value": "GEN-UNIQUE-8"
},
"publicIPAddressType": {
"value": "Dynamic"
},
"vmName": {
"value": "GEN-UNIQUE-8"
},
"vmSize": {
"value": "Standard_D3"
},
"adminUsername": {
"value": "GEN-UNIQUE"
},
"adminPassword": {
"value": "GEN-PASSWORD"
},
"virtualNetworkName": {
"value": "GEN-VNET-NAME"
},
"nicName": {
"value": "GEN-UNIQUE-8"
},
"vmExtensionName": {
"value": "GEN-UNIQUE-8"
}
}
}
You can visualize it from here :
http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fmcafee-extension-windows-vm%2Fazuredeploy.json
Hope it helps.
I have the below script, whch is a section of a script I'm using to deploy a vnet. However it fails to create a the vnet, any idea where I might be going wrong?
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"client": {
"type": "string",
"maxLength": 3,
"metadata": {
"description": "Client name - max 3 chars"
}
},
"environment": {
"type": "string",
"maxLength": 3,
"metadata": {
"description": "Environment name - max 3 chars"
}
},
"businessUnit": {
"type": "string",
"maxLength": 3,
"metadata": {
"description": "Business Unit name - max 3 chars"
}
},
"appName": {
"type": "string",
"maxLength": 3,
"metadata": {
"description": "App name - max 3 chars"
}
},
"addressPrefix": {
"type": "string",
"metadata": {
"description": "The address space in CIDR notation for the new virtual network."
}
},
"subnetName1": {
"type": "string",
"metadata": {
"description": "The name of the first subnet in the new virtual network."
}
},
"subnetName2": {
"type": "string",
"metadata": {
"description": "The name of the first subnet in the new virtual network."
}
},
"gatewaySubnet": {
"type": "string",
"defaultValue": "GatewaySubnet",
"allowedValues": [
"GatewaySubnet"
],
"metadata": {
"description": "The name of the subnet where Gateway is to be deployed. This must always be named GatewaySubnet."
}
},
"subnetPrefix1": {
"type": "string",
"metadata": {
"description": "The address range in CIDR notation for the first subnet."
}
},
"subnetPrefix2": {
"type": "string",
"metadata": {
"description": "The address range in CIDR notation for the first subnet."
}
},
"gatewaySubnetPrefix": {
"type": "string",
"metadata": {
"description": "The address range in CIDR notation for the Gateway subnet. For ExpressRoute enabled Gateways, this must be minimum of /28."
}
},
"dnsServerAddress": {
"type": "array",
"metadata": {
"Description": "The DNS address(es) of the DNS Server(s) used by the VNET"
}
},
"dnsServerAddressUpdateDns": {
"type": "array",
"metadata": {
"Description": "The DNS address(es) of the DNS Server(s) used by the VNET"
}
},
"vpnClientAddressPoolPrefix": {
"type": "string",
"metadata": {
"description": "The IP address range from which VPN clients will receive an IP address when connected. Range specified must not overlap with on-premise network."
}
},
"vmMfaName1privateIPAddress": {
"type": "string",
"metadata": {
"description": "The IP address of the MFA server."
}
},
"vmMfaName2privateIPAddress": {
"type": "string",
"metadata": {
"description": "The IP address of the MFA server."
}
},
"vmMfaLbIpAddress1": {
"type": "string",
"metadata": {
"description": "The IP address of the RADIUS server."
}
},
"radiusServerSecret": {
"type": "string",
"metadata": {
"description": "The secret of the RADIUS server."
}
},
"omsWorkSpaceResourceGroup": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Workspace Resource Group"
}
},
"omsWorkSpaceName": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Workspace Resource Name"
}
},
"omsWorkspaceStorageAccount": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Storage Account of OMS Workspace"
}
}
},
"variables": {
"apiVersion": "2015-06-15",
"vnetApiVersion": "2017-10-01",
"virtualNetworkPeeringApiVersion": "2017-10-01",
"routeTableApiVersion": "2017-10-01",
"locksApiVersion": "2017-04-01",
"virtualNetworkName": "[tolower(concat('vnet-', parameters('client'), '-', parameters('environment'), '-', parameters('businessUnit'), '-', parameters('appName')))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"gatewaySubnetRef": "[concat(variables('vnetID'),'/subnets/',parameters('gatewaySubnet'))]",
"virtualNetworkGatewayName": "[tolower(concat('vng-', parameters('client'), '-', parameters('environment'), '-', parameters('businessUnit'), '-', parameters('appName')))]",
"gatewaySku": "vpngw1",
"gatewayPublicIPName": "[tolower(concat('pip-', parameters('client'), '-', parameters('environment'), '-', parameters('businessUnit'), '-', parameters('appName')))]",
"vpnClientProtocols": "IkeV2",
"subnetName1": "[tolower(concat('sub-', parameters('client'), '-', parameters('environment'), '-', parameters('businessUnit'), '-', parameters('appName'), '-', parameters('subnetName1')))]",
"routeTable1": "[tolower(concat('udr-', variables('subnetName1')))]",
"networkSecurityGroup1": "[tolower(concat('nsg-', variables('subnetName1')))]",
"subnetName2": "[tolower(concat('sub-', parameters('client'), '-', parameters('environment'), '-', parameters('businessUnit'), '-', parameters('appName'), '-', parameters('subnetName2')))]",
"routeTable2": "[tolower(concat('udr-', variables('subnetName2')))]",
"networkSecurityGroup2": "[tolower(concat('nsg-', variables('subnetName2')))]"
},
"resources": [
{
"name": "[variables('routeTable1')]",
"type": "Microsoft.Network/routeTables",
"apiVersion": "[variables('routeTableApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [
],
"disableBgpRoutePropagation": false
}
},
{
"name": "[variables('routeTable2')]",
"type": "Microsoft.Network/routeTables",
"apiVersion": "[variables('routeTableApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [
],
"disableBgpRoutePropagation": false
}
},
{
"name": "[variables('networkSecurityGroup1')]",
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/networkSecurityGroups",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable1'))]"
],
"properties": {
"securityRules": [
{
"name": "AllowInboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "[parameters('addressPrefix')]",
"sourcePortRange": "*",
"destinationAddressPrefix": "*",
"destinationPortRange": "*"
}
},
{
"name": "AllowInboundHttpsMfaServer1",
"properties": {
"priority": 101,
"protocol": "Tcp",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('vmMfaName1privateIPAddress')]",
"destinationPortRange": "443"
}
},
{
"name": "AllowInboundHttpsMfaServer2",
"properties": {
"priority": 102,
"protocol": "Tcp",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('vmMfaName2privateIPAddress')]",
"destinationPortRange": "443"
}
},
{
"name": "AllowOutboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Outbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('addressPrefix')]",
"destinationPortRange": "*"
}
}
]
}
},
{
"type": "microsoft.network/networksecuritygroups/providers/diagnosticSettings",
"name": "[concat(variables('networkSecurityGroup1'), '/Microsoft.Insights/service')]",
"dependsOn": [
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup1'))]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "service",
"storageAccountId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('omsWorkSpaceResourceGroup'), '/providers/Microsoft.Storage/storageAccounts/', parameters('omsWorkspaceStorageAccount'))]",
"workspaceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('omsWorkSpaceResourceGroup'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('omsWorkSpaceName'))]",
"logs": [
{
"category": "NetworkSecurityGroupEvent",
"enabled": true,
"retentionPolicy": {
"days": 365,
"enabled": true
}
},
{
"category": "NetworkSecurityGroupRuleCounter",
"enabled": true,
"retentionPolicy": {
"days": 365,
"enabled": true
}
}
]
}
},
{
"name": "[variables('networkSecurityGroup2')]",
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/networkSecurityGroups",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable2'))]"
],
"properties": {
"securityRules": [
{
"name": "AllowInboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "[parameters('addressPrefix')]",
"sourcePortRange": "*",
"destinationAddressPrefix": "*",
"destinationPortRange": "*"
}
},
{
"name": "AllowOutboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Outbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('addressPrefix')]",
"destinationPortRange": "*"
}
}
]
}
},
{
"type": "microsoft.network/networksecuritygroups/providers/diagnosticSettings",
"name": "[concat(variables('networkSecurityGroup2'), '/Microsoft.Insights/service')]",
"dependsOn": [
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup2'))]"
],
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "service",
"storageAccountId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('omsWorkSpaceResourceGroup'), '/providers/Microsoft.Storage/storageAccounts/', parameters('omsWorkspaceStorageAccount'))]",
"workspaceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('omsWorkSpaceResourceGroup'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('omsWorkSpaceName'))]",
"logs": [
{
"category": "NetworkSecurityGroupEvent",
"enabled": true,
"retentionPolicy": {
"days": 365,
"enabled": true
}
},
{
"category": "NetworkSecurityGroupRuleCounter",
"enabled": true,
"retentionPolicy": {
"days": 365,
"enabled": true
}
}
]
}
},
{
"name": "[variables('virtualNetworkName')]",
"apiVersion": "[variables('vnetApiVersion')]",
"type": "Microsoft.Network/virtualNetworks",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable1'))]",
"[concat('Microsoft.Network/routeTables/', variables('routeTable2'))]",
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup1'))]",
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup2'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"dhcpOptions": {
"dnsServers": "[parameters('dnsServerAddress')]"
},
"subnets": [
{
"name": "[variables('subnetName1')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix1')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroup1'))]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTable1'))]"
},
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"[resourceGroup().location]"
]
},
{
"service": "Microsoft.Sql",
"locations": [
"[resourceGroup().location]"
]
}
]
}
},
{
"name": "[variables('subnetName2')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix2')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroup2'))]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTable2'))]"
},
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"[resourceGroup().location]"
]
},
{
"service": "Microsoft.Sql",
"locations": [
"[resourceGroup().location]"
]
}
]
}
},
{
"name": "[parameters('gatewaySubnet')]",
"properties": {
"addressPrefix": "[parameters('gatewaySubnetPrefix')]"
}
}
]
},
"resources": [
{
"name": "[concat(variables('virtualNetworkName'), '/Microsoft.Authorization/', variables('virtualNetworkName'), '-LockDoNotDelete')]",
"type": "Microsoft.Network/virtualNetworks/providers/locks",
"apiVersion": "[variables('locksApiVersion')]",
"dependsOn": [
"[variables('virtualNetworkName')]"
],
"properties": {
"level": "CanNotDelete",
"notes": "Resource Lock - Do Not Delete!",
"owners": [
]
}
}
]
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('gatewayPublicIPName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/virtualNetworkGateways",
"name": "[variables('virtualNetworkGatewayName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('gatewayPublicIPName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('gatewaySubnetRef')]"
},
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('gatewayPublicIPName'))]"
}
},
"name": "vnetGatewayConfig"
}
],
"sku": {
"name": "[variables('gatewaySku')]",
"tier": "[variables('gatewaySku')]"
},
"gatewayType": "Vpn",
"vpnType": "RouteBased",
"enableBgp": "false",
"vpnClientConfiguration": {
"vpnClientAddressPool": {
"addressPrefixes": [
"[parameters('vpnClientAddressPoolPrefix')]"
]
},
"vpnClientProtocols": [
"[variables('vpnClientProtocols')]"
],
"radiusServerAddress": "[parameters('vmMfaLbIpAddress1')]",
"radiusServerSecret": "[parameters('radiusServerSecret')]"
}
}
}
]
}
This is used to create a vnet and subnets before vm's are deployed to it.
I can't see where I'm going wrong, I'm baffled ..Any help would be appreciated Thanks
So, without you showing the exact error text, its pretty hard to tell what goes wrong exactly, i do have to admit template quality is mediocre. The most common error is wrong dependsOn property. Your typical dependsOn:
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup1'))]"
Proper dependsOn:
"[resourceId('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup1'))]"
You also have lots of places that could be improved, for example, why do you have parameter for gateway subnet name? It always is gatewaysubnet. You cannot change it. you are using prefixes for resource types instead of suffixes, you construct resource names in variables section and various other things which are used only once (for the most part) in the template (so just a waste of space). using concat() instead of resourceId() in many places:
"storageAccountId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('omsWorkSpaceResourceGroup'), '/providers/Microsoft.Storage/storageAccounts/', parameters('omsWorkspaceStorageAccount'))]",
"storageAccountId": "[resourceId(parameters('omsWorkSpaceResourceGroup'), 'Microsoft.Storage/storageAccounts', parameters('omsWorkspaceStorageAccount'))]",
second option is almost 2 times shorter...
I saw the question was marked as 'answered' this morning so i did post my yesterday finding, but since you are still having issue i will post them.
Yes, the template is not the greatest, seems it was put together by copying bit and piece from different templates.
With that been said i focused on the Network section that you mentioned you have issues with. Extract the network section, tweak a little to make up for missing parameters and variables and tried to deploy it. Noticed 2 issues
Issues
dnsserveraddress and dnsserveraddressupdatedns parameters had 'type' as array that did not really accepted any valid input.
Also got error that address space CIDR Notation you provided 10.10.2.0/22 is an invalid CIDR Notation.
Resolution
Once i correct both i was able to deploy the network section without any issues
Tweak JSON i used just to deploy VNet.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"addressPrefix": {
"type": "String",
"metadata": {
"description": "The address space in CIDR notation for the new virtual network."
}
},
"subnetName1": {
"type": "String",
"metadata": {
"description": "The name of the first subnet in the new virtual network."
}
},
"subnetName2": {
"type": "String",
"metadata": {
"description": "The name of the first subnet in the new virtual network."
}
},
"gatewaySubnet": {
"defaultValue": "GatewaySubnet",
"allowedValues": [
"GatewaySubnet"
],
"type": "String",
"metadata": {
"description": "The name of the subnet where Gateway is to be deployed. This must always be named GatewaySubnet."
}
},
"subnetPrefix1": {
"type": "String",
"metadata": {
"description": "The address range in CIDR notation for the first subnet."
}
},
"subnetPrefix2": {
"type": "String",
"metadata": {
"description": "The address range in CIDR notation for the first subnet."
}
},
"gatewaySubnetPrefix": {
"type": "String",
"metadata": {
"description": "The address range in CIDR notation for the Gateway subnet. For ExpressRoute enabled Gateways, this must be minimum of /28."
}
},
"dnsServerAddress": {
"type": "String",
"metadata": {
"Description": "The DNS address(es) of the DNS Server(s) used by the VNET"
}
},
"dnsServerAddressUpdateDns": {
"type": "String",
"metadata": {
"Description": "The DNS address(es) of the DNS Server(s) used by the VNET"
}
}
},
"variables": {
"apiVersion": "2015-06-15",
"vnetApiVersion": "2017-10-01",
"virtualNetworkPeeringApiVersion": "2017-10-01",
"routeTableApiVersion": "2017-10-01",
"locksApiVersion": "2017-04-01",
"virtualNetworkName": "[tolower(concat('vnet-Test'))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"gatewaySubnetRef": "[concat(variables('vnetID'),'/subnets/',parameters('gatewaySubnet'))]",
"subnetName1": "[tolower(concat('sub-', parameters('subnetName1')))]",
"routeTable1": "[tolower(concat('udr-', variables('subnetName1')))]",
"networkSecurityGroup1": "[tolower(concat('nsg-', variables('subnetName1')))]",
"subnetName2": "[tolower(concat('sub-', parameters('subnetName2')))]",
"routeTable2": "[tolower(concat('udr-', variables('subnetName2')))]",
"networkSecurityGroup2": "[tolower(concat('nsg-', variables('subnetName2')))]"
},
"resources": [
{
"type": "Microsoft.Network/routeTables",
"name": "[variables('routeTable1')]",
"apiVersion": "[variables('routeTableApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [],
"disableBgpRoutePropagation": false
}
},
{
"type": "Microsoft.Network/routeTables",
"name": "[variables('routeTable2')]",
"apiVersion": "[variables('routeTableApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"routes": [],
"disableBgpRoutePropagation": false
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('networkSecurityGroup1')]",
"apiVersion": "[variables('apiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "AllowInboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "[parameters('addressPrefix')]",
"sourcePortRange": "*",
"destinationAddressPrefix": "*",
"destinationPortRange": "*"
}
},
{
"name": "AllowOutboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Outbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('addressPrefix')]",
"destinationPortRange": "*"
}
}
]
},
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable1'))]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('networkSecurityGroup2')]",
"apiVersion": "[variables('apiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "AllowInboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Inbound",
"sourceAddressPrefix": "[parameters('addressPrefix')]",
"sourcePortRange": "*",
"destinationAddressPrefix": "*",
"destinationPortRange": "*"
}
},
{
"name": "AllowOutboundAnyAddressSpace",
"properties": {
"priority": 100,
"protocol": "*",
"access": "Allow",
"direction": "Outbound",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "[parameters('addressPrefix')]",
"destinationPortRange": "*"
}
}
]
},
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable2'))]"
]
},
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"apiVersion": "[variables('vnetApiVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('addressPrefix')]"
]
},
"dhcpOptions": {
"dnsServers": "[parameters('dnsServerAddress')]"
},
"subnets": [
{
"name": "[variables('subnetName1')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix1')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroup1'))]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTable1'))]"
},
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"[resourceGroup().location]"
]
},
{
"service": "Microsoft.Sql",
"locations": [
"[resourceGroup().location]"
]
}
]
}
},
{
"name": "[variables('subnetName2')]",
"properties": {
"addressPrefix": "[parameters('subnetPrefix2')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroup2'))]"
},
"routeTable": {
"id": "[resourceId('Microsoft.Network/routeTables', variables('routeTable2'))]"
},
"serviceEndpoints": [
{
"service": "Microsoft.Storage",
"locations": [
"[resourceGroup().location]"
]
},
{
"service": "Microsoft.Sql",
"locations": [
"[resourceGroup().location]"
]
}
]
}
},
{
"name": "[parameters('gatewaySubnet')]",
"properties": {
"addressPrefix": "[parameters('gatewaySubnetPrefix')]"
}
}
]
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks/providers/locks",
"name": "[concat(variables('virtualNetworkName'), '/Microsoft.Authorization/', variables('virtualNetworkName'), '-LockDoNotDelete')]",
"apiVersion": "[variables('locksApiVersion')]",
"properties": {
"level": "CanNotDelete",
"notes": "Resource Lock - Do Not Delete!",
"owners": []
},
"dependsOn": [
"[variables('virtualNetworkName')]"
]
}
],
"dependsOn": [
"[concat('Microsoft.Network/routeTables/', variables('routeTable1'))]",
"[concat('Microsoft.Network/routeTables/', variables('routeTable2'))]",
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup1'))]",
"[concat('Microsoft.Network/networksecuritygroups/', variables('networkSecurityGroup2'))]"
]
}
]
}
Hope this helps.
I am using this template enter link description here and I been working through it to convert it from stock to something I can use in the Azure Government Cloud. I am almost complete but I keep getting this last error that I do not know how to rectify. Maybe someone here with more json experience than I do can find this fix simply.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"uniquePrefix": {
"type": "string",
"metadata": {
"description": "This unique prefix will be used on all the objects created as part of this template."
}
},
"transferVMSize": {
"type": "string",
"defaultValue": "Standard_D4",
"allowedValues": [
"Standard_A4",
"Standard_A7",
"Standard_D4",
"Standard_D14",
"Standard_D2s_v3"
],
"metadata": {
"description": "Size of the VM used to transfer the VM image to various storage accounts."
}
},
"computeVMSize": {
"type": "string",
"defaultValue": "Standard_A1",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3",
"Standard_A4",
"Standard_A5",
"Standard_A6",
"Standard_A7",
"Standard_A8",
"Standard_A9",
"Standard_A10",
"Standard_A11",
"Standard_D1",
"Standard_D2",
"Standard_D3",
"Standard_D3_v2",
"Standard_D4",
"Standard_D4_v2",
"Standard_D5_v2",
"Standard_D11",
"Standard_D12",
"Standard_D12_v2",
"Standard_D13",
"Standard_D13_v2",
"Standard_D14",
"Standard_D14_v2",
"Standard_DS3",
"Standard_DS4",
"Standard_DS12",
"Standard_DS13",
"Standard_DS14",
"Standard_G2",
"Standard_G3",
"Standard_G4",
"Standard_G5",
"Standard_GS2",
"Standard_GS3",
"Standard_GS4",
"Standard_GS5",
"Standard_D2s_v3"
],
"metadata": {
"description": "Size of the VMs to be used for actual computation."
}
},
"computeOSType": {
"type": "string",
"defaultValue": "Linux",
"allowedValues": [
"Linux",
"Windows"
],
"metadata": {
"description": "Compute OS Type"
}
},
"deploymentType": {
"type": "string",
"defaultValue": "VMSS",
"allowedValues": [
"VMSS",
"Single",
"SingleAV"
],
"metadata": {
"description": "This determines whether the VMs will be deployed using scale sets, as individual VMs, or individual VMs in an availability set (maximum 100 for the last option)."
}
},
"numberOfSAs": {
"type": "int",
"metadata": {
"description": "Number of Storage Accounts to upload the custom image to."
}
},
"instanceCountPerSA": {
"type": "int",
"maxValue": 40,
"metadata": {
"description": "Number of VMs per Storage Account."
}
},
"imageLocation": {
"type": "string",
"metadata": {
"description": "URL of the base custom image, in the format of https://accountname.blob.core.windows.net/container/image.vhd."
}
},
"storageAccountKey": {
"type": "securestring",
"metadata": {
"description": "Storage Account key for accessing the base custom image."
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Admin username for the VMs in the deployment."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Admin password for the VMs in the deployment."
}
}
},
"variables": {
"vnetName": "[concat(parameters('uniquePrefix'), 'vnet')]",
"addressPrefix": "10.0.0.0/16",
"subnetName": "subnet",
"subnetPrefix": "10.0.0.0/21",
"transferImagePublisher": "Canonical",
"transferImageOffer": "UbuntuServer",
"ubuntuOSVersion": "16.04-LTS",
"imagePieces": "[split(parameters('imageLocation'),'/')]",
"blobName": "blob.core.usgovcloudapi.net",
"templateLocation": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/301-custom-images-at-scale/",
"sharedResourcesTemplateUri ": "[concat(variables('templateLocation'), 'shared-resources.json')]",
"finalTemplateUri": "[concat(variables('templateLocation'), 'final_')]",
"downloadTemplateURI": "[concat(variables('templateLocation'), 'download.json')]",
"downloadScriptURI": "[concat(variables('templateLocation'), 'download.sh')]",
"uploadTemplateURI": "[concat(variables('templateLocation'), 'upload.json')]",
"uploadScriptURI": "[concat(variables('templateLocation'), 'upload.sh')]",
"vmStorageAccountContainerName": "transfertestsa",
"OSDiskName": "transfertestvm",
"StorageAccountName": "transfertest"
},
"resources": [{
"name": "[concat(parameters('uniquePrefix'), 'base')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('sharedResourcesTemplateUri ')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"numberOfSAs": {
"value": "[parameters('numberOfSAs')]"
},
"vnetName": {
"value": "[variables('vnetName')]"
},
"addressPrefix": {
"value": "[variables('addressPrefix')]"
},
"subnetName": {
"value": "[variables('subnetName')]"
},
"subnetPrefix": {
"value": "[variables('subnetPrefix')]"
}
}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat('transfer', parameters('uniquePrefix'), 'sa')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"properties": {
"accountType": "Standard_LRS"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat('transfer', parameters('uniquePrefix'), 'ip')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('transfer', parameters('uniquePrefix'), 'nic')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/transfer', parameters('uniquePrefix'), 'ip')]",
"[concat('Microsoft.Resources/deployments/', parameters('uniquePrefix'), 'base')]"
],
"properties": {
"ipConfigurations": [{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat('transfer', parameters('uniquePrefix'), 'ip'))]"
},
"subnet": {
"id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('vnetName'), '/subnets/', variables('subnetName'))]"
}
}
}]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat('transfer', parameters('uniquePrefix'), 'vm')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/transfer', parameters('uniquePrefix'), 'sa')]",
"[concat('Microsoft.Network/networkInterfaces/transfer', parameters('uniquePrefix'), 'nic')]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('transferVMSize')]"
},
"osProfile": {
"computerName": "[concat('transfer', parameters('uniquePrefix'), 'vm')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('transferImagePublisher')]",
"offer": "[variables('transferImageOffer')]",
"sku": "[variables('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/',variables('vmStorageAccountContainerName'),''), '2015-06-15').primaryEndpoints.blob,'vhds/',variables('OSDiskName'),'-osdisk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat('transfer', parameters('uniquePrefix'), 'nic'))]"
}]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"storageUri": "[concat('http://transfer',parameters('uniquePrefix'),'sa.blob.core.usgovcloudapi.net')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'script0')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/transfer', parameters('uniquePrefix'), 'vm')]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('downloadTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"imageLocation": {
"value": "[parameters('imageLocation')]"
},
"storageAccountKey": {
"value": "[parameters('storageAccountKey')]"
},
"downloadScriptURI": {
"value": "[variables('downloadScriptURI')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'script', string(add(copyIndex(), 1)))]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"[concat('Microsoft.Resources/deployments/', parameters('uniquePrefix'), 'script', copyIndex())]"
],
"copy": {
"name": "uploadLoop",
"count": "[parameters('numberOfSAs')]"
},
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[variables('uploadTemplateURI')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"index": {
"value": "[copyIndex()]"
},
"uploadScriptURI": {
"value": "[variables('uploadScriptURI')]"
}
}
}
},
{
"name": "[concat(parameters('uniquePrefix'), 'full')]",
"type": "Microsoft.Resources/deployments",
"apiVersion": "2015-01-01",
"dependsOn": [
"uploadLoop"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('finalTemplateUri'), parameters('deploymentType'), '.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"uniquePrefix": {
"value": "[parameters('uniquePrefix')]"
},
"numberOfSAs": {
"value": "[parameters('numberOfSAs')]"
},
"instanceCountPerSA": {
"value": "[parameters('instanceCountPerSA')]"
},
"vmSize": {
"value": "[parameters('computeVMSize')]"
},
"OSType": {
"value": "[parameters('computeOSType')]"
},
"blobName": {
"value": "[variables('blobName')]"
},
"vnetName": {
"value": "[variables('vnetName')]"
},
"addressPrefix": {
"value": "[variables('addressPrefix')]"
},
"subnetName": {
"value": "[variables('subnetName')]"
},
"subnetPrefix": {
"value": "[variables('subnetPrefix')]"
},
"templateLocation": {
"value": "[variables('templateLocation')]"
},
"adminUsername": {
"value": "[parameters('adminUsername')]"
},
"adminPassword": {
"value": "[parameters('adminPassword')]"
}
}
}
}
]
}
The above is what I am using to launch my template and attached are the parameters that I am inputting and the error message I receive. enter image description hereenter image description here
I fixed the error by forking the script to my own repo and changing every occurrence of the blob reference to gov cloud in all the files needed for that script.
I would like to add in my template option for second disk based from "userImageStorageAccountName" My template was wrking until ii try to add second disk then when I try to deploy Vm i receive:
Blockquote {"code":"StorageAccountAlreadyExists","message":"The storage account named TEST already exists under the subscription."}}
But my target is to create in that storage account i don't want to create new storage account
BTW do you have maybe a nice documentation to create template for dummies :D
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.4.0",
"parameters": {
"VM_name": {
"type": "string",
"minLength": 11,
"maxLength": 12,
"defaultValue": "testxxx0021",
"metadata": {
"description": "Hostnem+dns name"
}
},
"VM_Class": {
"type": "string",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3"
],
"defaultValue": "Standard_A2",
"metadata": {
"description": "type VM"
}
},
"sizeOfEachDataDiskInGB": {
"type": "string",
"defaultValue": "20",
"metadata": {
"description": "Size of each data disk in GB"
}
},
"userImageStorageAccountName": {
"type": "string",
"defaultValue": "TEST",
"metadata": {
"description": "Storage account for machine"
}
},
"Windows_template": {
"type": "string",
"allowedValues": [
"https://TEST.blob.core.windows.net/system/Microsoft.Compute/Images/xxxxxxxx/template-dddosDisk.vhd",
"https://TEST.blob.core.windows.net/testtemp/xxxxxxx.vhd",
"https://TEST.blob.core.windows.net/testtemp/template-xxxxx.vhd"
],
"defaultValue": "https://TEST.blob.core.windows.net/TESTtemp/template-xxxxxxxxx.vhd",
"metadata": {
"description": "Uri of the your user image"
}
},
"adminUserName": {
"type": "securestring",
"defaultValue": "testadmin",
"metadata": {
"description": "UserName for the Virtual Machine"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine"
}
},
"osType": {
"type": "string",
"allowedValues": [
"Windows",
"Linux"
],
"defaultValue": "Windows",
"metadata": {
"description": "This is the OS that your VM will be running"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"vmName": "[parameters('VM_name')]",
"virtualNetworkName": "xx.xxx.xxx.0-xx-vnet",
"nicName": "[parameters('VM_name')]",
"addressPrefix": "xx.xxx.xxx.0/22",
"subnet1Name": "xx.xxx.xxx.0-xx-vnet",
"subnet1Prefix": "xx.xxx.xxx.0/24",
"vmStorageAccountContainerName": "vhds",
"storageAccountType": "Standard_LRS",
"storageAccountName": "[parameters('userImageStorageAccountName')]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
"osDiskVhdName": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/vhds/',variables('vmName'),'osDisk.vhd')]",
"apiVersion": "2015-06-15",
"dataDisk1VhdName": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "[variables('apiVersion')]",
"location": "[variables('location')]",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties": {
"addressPrefix": "[variables('subnet1Prefix')]"
}
}
]
}
},
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "[variables('apiVersion')]",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('VM_Class')]"
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"osDisk": {
"name": "[concat(variables('vmName'),'-osDisk')]",
"osType": "[parameters('osType')]",
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "[parameters('Windows_template')]"
},
"vhd": {
"uri": "[variables('osDiskVhdName')]"
}
}
},
"dataDisks": [
{
"name": "datadisk1",
"diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
"lun": 0,
"vhd": {
"Uri": "[variables('dataDisk1VhdName')]"
},
"createOption": "Empty"
}
],
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"storageUri": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net')]"
}
}
}
}
]
}
thx for Help
Looking over the JSON, you are requesting platform to ask user to provide a new storage account. To use exiting storage account you can refer existing parameter to you have already provided .
Original JSON :
"dataDisk1VhdName": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"
Suggested JSON
"dataDisk1VhdName": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"
Hope this helps.
Check if the storage account tags have been changed through the Azure/PowerShell portal by somebody else, and are different than the ones specified on the ARM template.
Sounds like a bug on the ARM deployment system, tags should be able to be updated but it is currently failing for storage account resources.
For more info see http://davidjrh.intelequia.com/2016/07/the-storage-account-already-exists.html