Private Endpoint for a Storage Queue in ARM - azure

I can create a Private Endpoint for a Storage Queue through the portal just fine and it works as intended when checking with nameresolver.exe from KUDU. However, I am struggling to find an ARM template that does this in one go.
I have made this template work but I can see that the A record entry does not get generated in the Private DNS Zone that is generated. I don't know how to create that A record entry and cannot seem to find a ARM template online that describes this:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"privateEndpointName": {
"type": "string",
"defaultValue": "privendpoint-sapriv01-queue"
},
"vnetName": {
"type": "string",
"defaultValue": "vn-myvnet01"
},
"subnetName": {
"type": "string",
"defaultValue": "sn-private-endpoints"
},
"groupId": {
"type": "string",
"defaultValue": "queue"
}
},
"variables": {
"privateDNSZone_name": "[concat('privatelink', '.queue.', environment().suffixes.storage)]"
},
"resources": [
{
"apiVersion": "2019-04-01",
"name": "[parameters('privateEndpointName')]",
"type": "Microsoft.Network/privateEndpoints",
"location": "[resourceGroup().Location]",
"properties": {
"privateLinkServiceConnections": [
{
"name": "[parameters('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.Storage/storageAccounts', 'saprivendpointdemo')]",
"groupIds": [
"[parameters('groupId')]"
]
}
}
],
"manualPrivateLinkServiceConnections": [],
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName') )]"
}
}
},
{
"type": "Microsoft.Network/privateDnsZones",
"apiVersion": "2018-09-01",
"name": "[variables('privateDNSZone_name')]",
"location": "global",
"tags": {},
"properties": {}
},
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2018-09-01",
"name": "[concat(variables('privateDNSZone_name'), '/', parameters('vnetName'), 'link' )]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('privateDNSZone_name'))]"
],
"properties": {
"virtualNetwork": {
"id": "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
},
"registrationEnabled": false
}
}
],
"outputs": {
}
}
I think Microsoft overcomplicated this. The Private IP is auto generated and I don't know how one would reference this IP in the ARM template.

If you want to add A record in your Azure Private DNS Zone, you can define Microsoft.Network/privateEndpoints/privateDnsZoneGroups in your template.
For example
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"privateEndpointName": {
"type": "string",
"defaultValue": "testqueue"
},
"vnetName": {
"type": "string",
"defaultValue": "teststorage"
},
"subnetName": {
"type": "string",
"defaultValue": "default"
},
"groupId": {
"type": "string",
"defaultValue": "queue"
}
},
"variables": {
"privateDNSZone_name": "[concat('privatelink', '.queue.', environment().suffixes.storage)]"
},
"resources": [
{
"apiVersion": "2019-04-01",
"name": "[parameters('privateEndpointName')]",
"type": "Microsoft.Network/privateEndpoints",
"location": "[resourceGroup().Location]",
"properties": {
"privateLinkServiceConnections": [
{
"name": "[parameters('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.Storage/storageAccounts', 'teststorage05')]",
"groupIds": [
"[parameters('groupId')]"
]
}
}
],
"manualPrivateLinkServiceConnections": [],
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName') )]"
}
}
},
{
"type": "Microsoft.Network/privateDnsZones",
"apiVersion": "2018-09-01",
"name": "[variables('privateDNSZone_name')]",
"dependsOn": [
"[parameters('privateEndpointName')]"
],
"location": "global",
"tags": {},
"properties": {}
},
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2018-09-01",
"name": "[concat(variables('privateDNSZone_name'), '/', parameters('vnetName'), 'link' )]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('privateDNSZone_name'))]"
],
"properties": {
"virtualNetwork": {
"id": "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
},
"registrationEnabled": false
}
},
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-03-01",
"name": "[concat(parameters('privateEndpointName'), '/', 'default')]",
"dependsOn": [
"[parameters('privateEndpointName')]",
"[variables('privateDNSZone_name')]"
],
"location": "[resourceGroup().Location]",
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privatelink-queue-core-windows-net",
"properties": {
"privateDnsZoneId": "[resourceId('Microsoft.Network/privateDnsZones',variables('privateDNSZone_name'))]"
}
}
]
}
}
],
"outputs": {
}
}
For more details, please refer to here and here

Related

Assigning Static Ip to nic(copy loop) in ARM template

I am trying to change dynamic private ip allocated VM to Static IP via ARM template.
It works for a single vm. But facing issue for multiple VM's deployment. I am trying nested deployment.
The error I am facing is: The template reference "nic-"somevmname"-01" is
not valid: could not find template resource or resource copy with this name.
I am not able to figure out what is wrong with the nested resource
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"VnetResourceGroup": {
"type": "string"
},
"VnetName": {
"type": "string"
},
"SubnetName": {
"type": "string"
},
"adminusername": {
"type": "string",
"metadata": {
"description": "Admin username for VM"
}
},
"adminpassword": {
"type": "string"
},
"vm-name": {
"type": "string",
"metadata": {
"description": ""
}
},
"virtualMachineCount": {
"type": "int",
"metadata": {
"description": "Number of Virtual machines to be deployed"
}
},
"vmSize": {
"type": "string",
"metadata": {
"description": "description"
}
},
"vm-image-name": {
"type": "string",
"metadata": {
"description": "description"
}
},
"vm-image-rg": {
"type": "string",
"metadata": {
"description": "description"
}
},
"dataDisksize": {
"type": "int"
},
"datadisks-count": {
"type": "int"
},
"osDiskType": {
"type": "string"
},
"osDiskSize": {
"type": "int",
"metadata": {
"description": "description"
}
},
"maxAvailabilityzones": {
"type": "int",
"metadata": {
"description": "description"
}
}
},
"variables": {
"ImageReferenceId": "[concat(subscription().id, '/resourceGroups/', parameters('vm-image-rg'), '/providers/Microsoft.Compute/images/', parameters('vm-image-name'))]",
"vnetId": "[concat(subscription().id, '/resourceGroups/', parameters('VnetResourceGroup'), '/providers/Microsoft.Network/virtualNetworks/', parameters('VnetName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]"
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('nic-',parameters('vm-name'),'-0', copyIndex(1))]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"copy": {
"name": "nicLoop",
"count": "[parameters('virtualMachineCount')]"
},
"properties": {
"enableAcceleratedNetworking": true,
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vm-name'),'-0', copyIndex(1))]",
"apiVersion": "2020-06-01",
"location": "[resourceGroup().location]",
"zones": [
"[string(add(mod(copyIndex(0), parameters('maxAvailabilityzones')), 1))]"
],
"copy": {
"name": "virtualMachineLoop",
"count": "[parameters('virtualMachineCount')]"
},
"dependsOn": [
"nicLoop"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[concat(parameters('vm-name'),'-0', copyIndex(1))]",
"adminusername": "[parameters('adminusername')]",
"adminPassword": "[parameters('adminpassword')]"
},
"storageProfile": {
"copy": [
{
"name": "dataDisks",
"count": "[parameters('datadisks-count')]",
"input": {
"lun": "[copyIndex('dataDisks')]",
"name": "[concat('dataDisk',copyIndex('dataDisks',1),'-',parameters('vm-name'),'-0',copyIndex(1))]",
"createOption": "Empty",
"diskSizeGB": "[parameters('dataDisksize')]"
}
}
],
"imageReference": { "id": "[variables('ImageReferenceId')]" },
"osDisk": {
"name": "[concat('osdisk-',parameters('vm-name'),'-0', copyIndex(1))]",
"createOption": "FromImage",
"caching": "ReadWrite",
"diskSizeGB": "[parameters('osDiskSize')]",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat('nic-',parameters('vm-name'),'-0', copyIndex(1)))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
}
}
},
{
"type": "Microsoft.Resources/deployments",
"name": "StaticIP",
"apiVersion": "2020-06-01",
"dependsOn": [
"nicLoop",
"virtualMachineLoop"
],
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"parameters": {
"SubnetRef": {
"value": "[variables('SubnetRef')]"
},
"virtualMachineCount": {
"value": "[parameters('virtualMachineCount')]"
},
"vm-name": {
"value": "[parameters('vm-name')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subnetRef": {
"type": "string"
},
"virtualMachineCount": {
"type": "int",
"metadata": {
"description": "Number of Virtual machines to be deployed"
}
},
"vm-name": {
"type": "string",
"metadata": {
"description": "description"
}
}
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('assignstaticip',copyIndex(1))]",
"apiVersion": "2020-05-01",
"location": "[resourceGroup().location]",
"copy": {
"name": "nicStaticIpLoop",
"count": "[parameters('virtualMachineCount')]"
},
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[reference(concat('nic-',parameters('vm-name'),'-0', copyIndex('nicStaticIpLoop',1))).ipConfigurations[0].properties.privateIPAddress]",
"subnet": {
"id": "[parameters('subnetRef')]"
}
}
}
]
}
}
]
}
}
}
],
"outputs": {
"vm-ipaddress": {
"type": "array",
"copy": {
"count": "[parameters('virtualMachineCount')]",
"input": "[reference(concat('nic-',parameters('vm-name'),'-0', copyIndex(1))).ipConfigurations[0].properties.privateIPAddress]"
}
},
"vm-name": {
"type": "array",
"copy": {
"count": "[parameters('virtualMachineCount')]",
"input": "[concat(parameters('vm-name'),'-0', copyIndex(1))]"
}
}
}
}
Thank you #Anonymouus, for sharing the update . And bring the question for how to change dynamic private ip allocated VM to Static IP via ARM template, It will be really helpful for the SO community for similar issue who encounter the same so that they can find & fix their problem by posting it as an answer .
As stated in the given Blog which is Author by #Praveen.
To change the dynamic IP to static IP through ARM TEMPLATE we can use the below example of template,
ARM TEMPLATE:-
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2018-05-01",
"name": "[concat('StaticIp', copyIndex())]",
"dependsOn": [
"nicLoop"
],
"copy": {
"name": "ipLoop",
"count": "[parameters('ServerInstanceCount')]"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(parameters('ServerNamePrefix'),padLeft(copyIndex(),3,'0'),'-NIC')]",
"apiVersion": "2018-03-01",
"location": "[resourceGroup().location]",
"tags": "[parameters('tagValues')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[reference(concat(parameters('ServerNamePrefix'),padLeft(copyIndex(),3,'0'),'-NIC')).ipConfigurations[0].properties.privateIPAddress]",
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"enableAcceleratedNetworking": true
}
}
]
}
}
}
For more information please refer the below links:-
SO THREAD| Static ip addresses on Azure & Nested Copy loop using ARM Template.

ARM Template Coginitive services

I need a ARM template for Form Recognizer. It would be helpful if anyone can share a working template for this
ARM template for Form Recognizer
We have tried to create form recognizer in Azure and test the deployment using below template.
ARM TEMPLETE:-
sample.json
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"location": {
"type": "string"
},
"resourceGroupName": {
"type": "string"
},
"resourceGroupId": {
"type": "string"
},
"sku": {
"type": "string"
},
"tagValues": {
"type": "object"
},
"virtualNetworkType": {
"type": "string"
},
"vnet": {
"type": "object"
},
"ipRules": {
"type": "array"
},
"identity": {
"type": "object"
},
"privateEndpoints": {
"type": "array"
},
"isCommitmentPlanForDisconnectedContainerEnabled": {
"type": "bool"
},
"commitmentPlanForDisconnectedContainer": {
"type": "object"
}
},
"variables": {
"defaultVNetName": "frCSDefaultVNet9901",
"defaultSubnetName": "frCSDefaultSubnet9901",
"defaultAddressPrefix": "13.41.6.0/26"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "deployVnet",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-04-01",
"name": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').name, variables('defaultVNetName'))]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').addressPrefixes, json(concat('[{\"', variables('defaultAddressPrefix'),'\"}]')))]"
},
"subnets": [
{
"name": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').subnets.subnet.name, variables('defaultSubnetName'))]",
"properties": {
"serviceEndpoints": [
{
"service": "Microsoft.CognitiveServices",
"locations": [
"[parameters('location')]"
]
}
],
"addressPrefix": "[if(equals(parameters('virtualNetworkType'), 'External'), parameters('vnet').subnets.subnet.addressPrefix, variables('defaultAddressPrefix'))]"
}
}
]
}
}
]
},
"parameters": {}
},
"condition": "[and(and(not(empty(parameters('vnet'))), equals(parameters('vnet').newOrExisting, 'new')), equals(parameters('virtualNetworkType'), 'External'))]"
},
{
"apiVersion": "2021-04-30",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"type": "Microsoft.CognitiveServices/accounts",
"kind": "FormRecognizer",
"tags": "[if(contains(parameters('tagValues'), 'Microsoft.CognitiveServices/accounts'), parameters('tagValues')['Microsoft.CognitiveServices/accounts'], json('{}'))]",
"sku": {
"name": "[parameters('sku')]"
},
"identity": "[parameters('identity')]",
"properties": {
"customSubDomainName": "[toLower(parameters('name'))]",
"publicNetworkAccess": "[if(equals(parameters('virtualNetworkType'), 'Internal'), 'Disabled', 'Enabled')]",
"networkAcls": {
"defaultAction": "[if(equals(parameters('virtualNetworkType'), 'External'), 'Deny', 'Allow')]",
"virtualNetworkRules": "[if(equals(parameters('virtualNetworkType'), 'External'), json(concat('[{\"id\": \"', concat(subscription().id, '/resourceGroups/', parameters('vnet').resourceGroup, '/providers/Microsoft.Network/virtualNetworks/', parameters('vnet').name, '/subnets/', parameters('vnet').subnets.subnet.name), '\"}]')), json('[]'))]",
"ipRules": "[if(or(empty(parameters('ipRules')), empty(parameters('ipRules')[0].value)), json('[]'), parameters('ipRules'))]"
}
},
"resources": [
{
"type": "commitmentPlans",
"apiVersion": "2021-10-01",
"name": "DisconnectedContainer-FormRecognizer-1",
"properties": "[parameters('commitmentPlanForDisconnectedContainer')]",
"condition": "[parameters('isCommitmentPlanForDisconnectedContainerEnabled')]",
"dependsOn": [
"[parameters('name')]"
]
}
],
"dependsOn": [
"[concat('Microsoft.Resources/deployments/', 'deployVnet')]"
]
},
{
"apiVersion": "2017-05-10",
"name": "[concat('deployPrivateEndpoint-', parameters('privateEndpoints')[copyIndex()].privateEndpoint.name)]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('privateEndpoints')[copyIndex()].resourceGroup.value.name]",
"subscriptionId": "[parameters('privateEndpoints')[copyIndex()].subscription.subscriptionId]",
"dependsOn": [
"[parameters('name')]"
],
"condition": "[equals(parameters('virtualNetworkType'), 'Internal')]",
"copy": {
"name": "privateendpointscopy",
"count": "[length(parameters('privateEndpoints'))]"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"location": "[parameters('location')]",
"name": "[parameters('privateEndpoints')[copyIndex()].privateEndpoint.name]",
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-03-01",
"properties": {
"subnet": {
"id": "[parameters('privateEndpoints')[copyIndex()].privateEndpoint.properties.subnet.id]"
},
"privateLinkServiceConnections": [
{
"name": "[parameters('privateEndpoints')[copyIndex()].privateEndpoint.name]",
"properties": {
"privateLinkServiceId": "[concat(parameters('resourceGroupId'), '/providers/Microsoft.CognitiveServices/accounts/', parameters('name'))]",
"groupIds": "[parameters('privateEndpoints')[copyIndex()].privateEndpoint.properties.privateLinkServiceConnections[0].properties.groupIds]"
}
}
]
},
"tags": {}
}
]
}
}
},
{
"apiVersion": "2017-05-10",
"name": "[concat('deployDnsZoneGroup-', parameters('privateEndpoints')[copyIndex()].privateEndpoint.name)]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('privateEndpoints')[copyIndex()].resourceGroup.value.name]",
"subscriptionId": "[parameters('privateEndpoints')[copyIndex()].subscription.subscriptionId]",
"dependsOn": [
"[concat('Microsoft.Resources/deployments/', concat('deployPrivateEndpoint-', parameters('privateEndpoints')[copyIndex()].privateEndpoint.name))]"
],
"condition": "[equals(parameters('virtualNetworkType'), 'Internal')]",
"copy": {
"name": "privateendpointdnscopy",
"count": "[length(parameters('privateEndpoints'))]"
},
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-03-01",
"name": "[concat(parameters('privateEndpoints')[copyIndex()].privateEndpoint.name, '/', 'default')]",
"location": "[parameters('location')]",
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privatelink-cognitiveservices-azure-com",
"properties": {
"privateDnsZoneId": "[concat(parameters('resourceGroupId'), '/providers/Microsoft.Network/privateDnsZones/privatelink.cognitiveservices.azure.com')]"
}
}
]
}
}
]
}
}
}
]
}
We have Saved the parameters in different file and deploy with referencing deployment file as below.
azuredeploy.parameter.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name":{
"value": "myrecognizer"
},
"location": {
"value": "westus2"
},
"resourceGroupName":{
"value": "my_resource_group"
},
"resourceGroupId": {
"value": "/subscriptions/subscID/resourceGroups/my_resource_group"
},
"sku":{
"value": "S0"
},
"tagValues":{
"value": {}
},
"virtualNetworkType":{
"value": "None"
},
"vnet":{
"value": {}
},
"ipRules":{
"value": []
},
"identity":{
"value": {
"type": "None"
}
},
"privateEndpoints":{
"value":[]
},
"isCommitmentPlanForDisconnectedContainerEnabled":{
"value": false
},
"commitmentPlanForDisconnectedContainer":{
"value": {
"current": {},
"hostingModel": "DisconnectedContainer",
"planType": "CustomInvoice",
"autoRenew": true
}
}
}
}
Deploy using below cmd in terminal :
az deployment group create -n TestDeployment -g myresourcegroup --template-file "C:\locationfile\sample.json" --parameters "C:\locationfile\azuredeploy.parameters.json"
Below are the SCREENSHOT FOR DEPLOYMENT DETAILS:-

ARM Template to create SQL Database with a privatendpoint

I'm having errors while trying to deploy an ARM deploy with an SQL Database and its private endpoint.
here is the code below
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlAdministratorLogin": {
"type": "string",
"metadata": {
"description": "The administrator username of the SQL logical server"
}
},
"sqlAdministratorLoginPassword": {
"type": "securestring",
"metadata": {
"description": "The administrator password of the SQL logical server."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"vnetName": "powerStateManagement-vnet",
"subnet1Name": "default",
"sqlServerName": "[concat('sqlserver', uniqueString(resourceGroup().id))]",
"databaseName": "[concat(variables('sqlServerName'),'/sample-db')]",
"privateEndpointName": "myPrivateEndpoint",
"privateDnsZoneName": "[concat('privatelink', environment().suffixes.sqlServerHostname)]",
"pvtendpointdnsgroupname": "[concat(variables('privateEndpointName'),'/mydnsgroupname')]",
"vnetResourceGroup":"powerStateManagement"
},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2020-02-02-preview",
"name": "[variables('sqlServerName')]",
"location": "[parameters('location')]",
"kind": "v12.0",
"tags": {
"displayName": "[variables('sqlServerName')]"
},
"properties": {
"administratorLogin": "[parameters('sqlAdministratorLogin')]",
"administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]",
"version": "12.0",
"publicNetworkAccess": "Disabled"
},
"resources": [
]
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2020-02-02-preview",
"name": "[variables('databaseName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 5
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', variables('sqlServerName'))]"
],
"tags": {
"displayName": "[variables('databaseName')]"
},
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": 104857600,
"requestedServiceObjectiveName": "Basic",
"sampleName": "AdventureWorksLT"
}
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-06-01",
"name": "[variables('privateEndpointName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[variables('vnetName')]",
"[variables('sqlServerName')]"
],
"properties": {
"subnet": {
"id": "[resourceId(variables('vnetResourceGroup'),'/','Microsoft.Network/virtualNetworks','/',variables('vnetName'),'/',variables('subnet1Name'))]"
},
"privateLinkServiceConnections": [
{
"name": "[variables('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.Sql/servers',variables('sqlServerName'))]",
"groupIds": [
"sqlServer"
]
}
}
]
}
},
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2020-01-01",
"name": "[concat(variables('privateDnsZoneName'), '/', variables('privateDnsZoneName'), '-link')]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('privateDnsZoneName'))]",
"[resourceId(variables('vnetResourceGroup'),'Microsoft.Network/virtualNetworks',variables('vnetName'))]"
],
"properties": {
"registrationEnabled": false,
"virtualNetwork": {
"id": "/subscriptions/*****/resourceGroups/powerStateManagement/providers/Microsoft.Network/virtualNetworks/powerStateManagement-vnet"
}
}
},
{
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-06-01",
"name": "[variables('pvtendpointdnsgroupname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('privateDnsZoneName'))]",
"[variables('privateEndpointName')]"
],
"properties": {
"privateDnsZoneConfigs": [
{
"name": "config1",
"properties": {
"privateDnsZoneId": "[resourceId('Microsoft.Network/privateDnsZones', variables('privateDnsZoneName'))]"
}
}
]
}
}
]
}
The challenge here is that when I try to run this code I always get this error
Deployment template validation failed: 'The template reference 'powerStateManagement-vnet' is not valid: could not find template resource or resource copy with this name.
The ''powerStateManagement-vnet' is an existing Virtual Network which has been referenced below
{
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2020-01-01",
"name": "[concat(variables('privateDnsZoneName'), '/', variables('privateDnsZoneName'), '-link')]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/privateDnsZones', variables('privateDnsZoneName'))]",
"[resourceId(variables('vnetResourceGroup'),'Microsoft.Network/virtualNetworks',variables('vnetName'))]"
],
"properties": {
"registrationEnabled": false,
"virtualNetwork": {
"id": "/subscriptions/*****/resourceGroups/powerStateManagement/providers/Microsoft.Network/virtualNetworks/powerStateManagement-vnet"
}
}
}
Please help
There is something wrong with your dependsOn param of Microsoft.Network/privateEndpoints. And seems there are some other issues in your template, I did some modification based on your template,just try it below:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlAdministratorLogin": {
"type": "string",
"metadata": {
"description": "The administrator username of the SQL logical server"
}
},
"sqlAdministratorLoginPassword": {
"type": "securestring",
"metadata": {
"description": "The administrator password of the SQL logical server."
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"vnetName": "powerStateManagement-vnet",
"subnet1Name": "default",
"sqlServerName": "[concat('sqlserver', uniqueString(resourceGroup().id))]",
"databaseName": "[concat(variables('sqlServerName'),'/sample-db')]",
"privateEndpointName": "myPrivateEndpoint",
"privateDnsZoneName": "testdns.com",
"pvtendpointdnsgroupname": "[concat(variables('privateEndpointName'),'/mydnsgroupname')]",
"vnetResourceGroup": "powerStateManagement"
},
"resources": [{
"type": "Microsoft.Sql/servers",
"apiVersion": "2020-02-02-preview",
"name": "[variables('sqlServerName')]",
"location": "[parameters('location')]",
"kind": "v12.0",
"tags": {
"displayName": "[variables('sqlServerName')]"
},
"properties": {
"administratorLogin": "[parameters('sqlAdministratorLogin')]",
"administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]",
"version": "12.0",
"publicNetworkAccess": "Disabled"
},
"resources": [
]
}, {
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2020-02-02-preview",
"name": "[variables('databaseName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 5
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', variables('sqlServerName'))]"
],
"tags": {
"displayName": "[variables('databaseName')]"
},
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": 104857600,
"requestedServiceObjectiveName": "Basic",
"sampleName": "AdventureWorksLT"
}
}, {
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-06-01",
"name": "[variables('privateEndpointName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"[resourceId('Microsoft.Sql/servers', variables('sqlServerName'))]"
],
"properties": {
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('vnetName')),'/subnets/default')]"
},
"privateLinkServiceConnections": [{
"name": "[variables('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.Sql/servers',variables('sqlServerName'))]",
"groupIds": [
"sqlServer"
]
}
}
]
}
}, {
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-05-01",
"name": "[variables('vnetName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"172.22.0.0/16"
]
}
},
"resources": [{
"type": "subnets",
"apiVersion": "2020-05-01",
"location": "[resourceGroup().location]",
"name": "default",
"dependsOn": [
"[variables('vnetName')]"
],
"properties": {
"addressPrefix": "172.22.0.0/24",
"privateEndpointNetworkPolicies": "Disabled"
}
}
]
}, {
"type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks",
"apiVersion": "2020-01-01",
"name": "[concat(variables('privateDnsZoneName'), '/', variables('privateDnsZoneName'), '-link')]",
"location": "global",
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
],
"properties": {
"registrationEnabled": false,
"virtualNetwork": {
"id":"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
}
}
}, {
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-06-01",
"name": "[variables('pvtendpointdnsgroupname')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/privateEndpoints', variables('privateEndpointName'))]"
],
"properties": {
"privateDnsZoneConfigs": [{
"name": "config1",
"properties": {
"privateDnsZoneId": "[resourceId('Microsoft.Network/privateDnsZones', variables('privateDnsZoneName'))]"
}
}
]
}
}
]
}
This template creates a new virtual network with a default subnet together, I use my own private DNS zone named : testdns.com. I have tested on my side by powershell and it works for me.
Result

Azure ARM Template DependentOn FileShare

I need to create via ARM template storage account --> File share --> Container with mounted fileshare.
The dependency is:
file share depends on storage account
container depends on file share
How to get ReferenceId of Fileshare?
I have the following code:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS"
],
"metadata": {
"description": "Storage account type (SKU)"
}
},
"fileShareName": {
"type": "string",
"minLength": 3,
"maxLength": 63,
"defaultValue": "sftp",
"metadata": {
"description": "Name of the File Share to be created. "
}
}
},
"variables": {
"deploymentLocation": "[resourceGroup().location]",
"storageAccountName": "[concat('sftpstr', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2019-06-01",
"location": "[variables('deploymentLocation')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2019-06-01",
"properties": {
"accessTier": "Hot"
},
"name": "[concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.ContainerInstance/containerGroups",
"name": "sftp-container-group",
"apiVersion": "2018-04-01",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', ????? )]" //how to get reference to specific Fileshare??? I've tried > [concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))] but it didn't work
],
"properties": {
.......
}
}
]
}
and I don't know how to set dependency on Fileshare:
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', ????? )]" //how to get reference to specific Fileshare???
],
I've tried [concat(variables('storageAccountName'), '/default/', parameters('fileShareName'))] but it didn't work.
Any idea?
Thank you
Use following format:
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', variables('storageAccountName') , 'default', parameters('fileShareName') )]"
],
You could create two separate resources Microsoft.Storage/storageAccounts/fileServices and Microsoft.Storage/storageAccounts/fileServices/shares and try to set dependency on Fileshare like this:
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', variables('storageAccountName'), 'default', parameters('fileShareName') )]"
],
Alternatively, It's recommended to creates a storage account and a file share via azure-CLI in a Container Instance and refer to this quickstart template.
"variables": {
"image": "microsoft/azure-cli",
"cpuCores": "1.0",
"memoryInGb": "1.5",
"containerGroupName": "createshare-containerinstance",
"containerName": "createshare"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccountName')]",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "StorageV2"
},
{
"name": "[variables('containerGroupName')]",
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2019-12-01",
"location": "[parameters('containerInstanceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
],
"properties": {
"containers": [
{
"name": "[variables('containerName')]",
"properties": {
"image": "[variables('image')]",
"command": [
"az",
"storage",
"share",
"create",
"--name",
"[parameters('fileShareName')]"
],
"environmentVariables": [
{
"name": "AZURE_STORAGE_KEY",
"value": "[listKeys(parameters('storageAccountName'),'2019-06-01').keys[0].value]"
},
{
"name": "AZURE_STORAGE_ACCOUNT",
"value": "[parameters('storageAccountName')]"
}
],
"resources": {
"requests": {
"cpu": "[variables('cpuCores')]",
"memoryInGb": "[variables('memoryInGb')]"
}
}
}
}
],
"restartPolicy": "OnFailure",
"osType": "Linux"
}
}
]
I found a couple of things that made it work for me:
ACI has to depend on the share otherwise it gets created ahead of volume sometimes
"dependsOn": ["resourceId('Microsoft.Storage/storageAccounts/fileServices/shares',variables('storage-account-name'), 'default', variables('file-share-name'))]"]
For some reason, the share wasn't working as a child resource so I had to make it a full resource
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-04-01",
"name": "[concat(variables('storage-account-name'),'/default/',variables('nginx-share-name'))]",
"properties":{
"enabledProtocols": "SMB"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storage-account-name'))]"
]
}
Also, I had to pay attention to default part of the resource ID
"name": "[concat(variables('storage-account-name'),'/default/',variables('nginx-share-name'))]"
And finally, ACI wasn't connecting properly unless I explicitly enabled SMB as a protocol
"properties":{
"enabledProtocols": "SMB"
}
This is a template I'm using to spin up NGINX in Azure Container instances with an Azure File Share as a mounted volume.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"containerGroups_name": {
"defaultValue": "container-app",
"type": "String"
},
"containerGroups_reverse_proxy_name": {
"defaultValue": "app-proxy",
"type": "String"
},
"acrPassword": {
"type": "securestring"
}
},
"variables": {
"nginx-proxy-image": "nginx:stable",
"storage-account-name": "[concat('storage', uniqueString(resourceGroup().name))]",
"nginx-share-name": "nginx-share",
"nginx-volume-name": "nginx-volume"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-10-01",
"name": "[variables('storage-account-name')]" ,
"location": "[resourceGroup().location]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2021-04-01",
"name": "[concat(variables('storage-account-name'),'/default/',variables('nginx-share-name'))]",
"properties":{
"enabledProtocols": "SMB"
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storage-account-name'))]"
]
},
{
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2021-03-01",
"name": "[parameters('containerGroups_name')]",
"location": "[resourceGroup().location]",
"properties": {
"sku": "Standard",
"containers": [
{
"name": "[parameters('containerGroups_reverse_proxy_name')]",
"properties" : {
"image": "[variables('nginx-proxy-image')]",
"ports": [
{
"protocol": "TCP",
"port": 80
},
{
"protocol": "TCP",
"port": 433
}
],
"volumeMounts" : [
{
"name": "[variables('nginx-volume-name')]",
"mountPath": "/etc/nginx"
}
],
"resources": {
"requests":{
"cpu": 1,
"memoryInGB": 1.5
}
}
}
}
],
"initContainers": [],
"restartPolicy": "OnFailure",
"osType": "Linux",
"volumes": [
{
"name": "[variables('nginx-volume-name')]",
"azureFile": {
"shareName": "[variables('nginx-share-name')]",
"storageAccountName": "[variables('storage-account-name')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts',variables('storage-account-name')),'2017-10-01').keys[0].value]"
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares',variables('storage-account-name'), 'default', variables('nginx-share-name'))]"
]
}
]
}

azure SQL DB import with copy

I am working on an ARM template that will ask for a comma separated list of db names and then create them using the copyIndex function. This aspect is working great but the next step of my solution is not. What I would like to do next is Import a .bacpac file for each database so that it is ready for use upon completion.
The validation error indicates the issue is with the concat function in the Import resource dependsOn. I have tested it a handful of different ways and can not see where it is wrong.
The exact error message I am seeing is....
Unable to process template language expressions for resource '/subscriptions/xxxxxx-xxxxx-xxxxxx-xxxxx/resourceGroups/testGroup/providers/Microsoft.Sql/servers/testsql/databases/CustomersDB/extensions/import' at line '858' and column '10'. 'The provided parameters for language function 'concat' are invalid. Either all or none of the parameters must be an array.
**added entire template
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "centralus"
},
"sqlAdminUsername": {
"type": "string"
},
"sqlAdminPassword": {
"type": "securestring"
},
"sqlServerName": {
"type": "string"
},
"sqlDatabaseNames": {
"type": "array",
"defaultValue": [
"CustomersDB",
"WideWorldImporters-Standard"
]
},
"sqlEdition": {
"type": "string",
"defaultValue": "Standard"
},
"sqlRequestedServiceObjectiveName": {
"type": "string",
"defaultValue": "S2"
},
"sqlMaxSizeBytes": {
"type": "string",
"defaultValue": "268435456000"
},
"publicIP": {
"type": "string"
},
"_artifactsLocationSasToken": {
"type": "securestring"
},
"_artifactsLocation": {
"type": "string"
}
},
"variables": {
"storageKeyType": "SharedAccessKey",
"collation": "SQL_Latin1_General_CP1_CI_AS"
},
"resources": [
{
"name": "[parameters('sqlServerName')]",
"type": "Microsoft.Sql/servers",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('sqlAdminUsername')]",
"administratorLoginPassword": "[parameters('sqlAdminPassword')]",
"version": "12.0"
},
"resources": [
{
"name": "AllowAllWindowsAzureIps",
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
}
},
{
"name": "Allow_Remote_SSMS",
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"startIpAddress": "[parameters('publicIP')]",
"endIpAddress": "[parameters('publicIP')]"
}
}
]
},
{
"name": "[concat(parameters('sqlServerName'), '/', parameters('sqlDatabaseNames')[copyIndex()])]",
"type": "Microsoft.Sql/servers/databases",
"location": "[parameters('location')]",
"apiVersion": "2014-04-01-preview",
"copy": {
"count": "[length(parameters('sqlDatabaseNames'))]",
"name": "sql-copy"
},
"dependsOn": [ "[resourceId('Microsoft.Sql/servers/', parameters('sqlServerName'))]" ],
"properties": {
"collation": "[variables('collation')]",
"edition": "[parameters('sqlEdition')]",
"maxSizeBytes": "[parameters('sqlMaxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('sqlRequestedServiceObjectiveName')]"
}
},
{
"name": "[concat(parameters('sqlServerName'), '/', parameters('sqlDatabaseNames')[copyIndex()],'/','import')]",
"type": "Microsoft.Sql/servers/databases/extensions",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ "sql-copy" ],
"copy": {
"name": "sql-import",
"count": "[length(parameters('sqlDatabaseNames'))]"
},
"properties": {
"storageKeyType": "[variables('storageKeyType')]",
"storageKey": "[parameters('_artifactsLocationSasToken')]",
"storageUri": "[concat(parameters('_artifactsLocation'), '/', 'databaseFiles', '/', parameters('sqlDatabaseNames'), '.bacpac')]",
"administratorLogin": "[parameters('sqlAdminUsername')]",
"administratorLoginPassword": "[parameters('sqlAdminPassword')]",
"operationMode": "Import"
}
}
],
}
As far as I know, we couldn't use the copyindex function in the nested resources.
If you run your arm template, you will face this error:
Copying nested resources is not supported. Please see https://aka.ms/arm-copy/#looping-on-a-nested-resource for usage details.'.
So I suggest you move the nested resources as root resources in arm template. Then you could use the copyindex.
More details, you could refer to below arm template:
Notice: Replace the parameter orb with your database name.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"brandosqlAdminLogin": {
"type": "string",
"minLength": 1
},
"brandosqlAdminLoginPassword": {
"type": "string"
},
"org": {
"type": "array",
"defaultValue": [
"contoso",
"fabrikam",
"coho"
]
},
"copydatabaseCollation": {
"type": "string",
"minLength": 1,
"defaultValue": "SQL_Latin1_General_CP1_CI_AS"
},
"copydatabaseEdition": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"Standard",
"Premium"
]
},
"copydatabaseRequestedServiceObjectiveName": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"S0",
"S1",
"S2",
"P1",
"P2",
"P3"
],
"metadata": {
"description": "Describes the performance level for Edition"
}
},
"copy2StorageKeyType": {
"type": "string",
"minLength": 1
},
"copy2StorageKey": {
"type": "string"
},
"copy2StorageUri": {
"type": "string",
"minLength": 1
},
"copy2AdministratorLogin": {
"type": "string",
"minLength": 1
},
"copy2AdministratorLoginPassword": {
"type": "string"
},
"serverDatabaseName": {
"type": "array",
"defaultValue": [
"brandoimprottest/contoso",
"brandoimprottest/fabrikam",
"brandoimprottest/coho"
]
},
"copysqldatabase2Collation": {
"type": "string",
"minLength": 1,
"defaultValue": "SQL_Latin1_General_CP1_CI_AS"
},
"copysqldatabase2Edition": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"Standard",
"Premium"
]
},
"copysqldatabase2RequestedServiceObjectiveName": {
"type": "string",
"defaultValue": "Basic",
"allowedValues": [
"Basic",
"S0",
"S1",
"S2",
"P1",
"P2",
"P3"
],
"metadata": {
"description": "Describes the performance level for Edition"
}
}
},
"variables": {
"brandosqlName": "brandoimprottest"
},
"resources": [
{
"name": "[variables('brandosqlName')]",
"type": "Microsoft.Sql/servers",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [],
"tags": {
"displayName": "brandosql"
},
"properties": {
"administratorLogin": "[parameters('brandosqlAdminLogin')]",
"administratorLoginPassword": "[parameters('brandosqlAdminLoginPassword')]"
},
"resources": [
{
"name": "AllowAllWindowsAzureIps",
"type": "firewallrules",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', variables('brandosqlName'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
}
}
]
},
{
"name": "[concat(variables('brandosqlName'), '/', parameters('org')[copyIndex()])]",
"type": "Microsoft.Sql/servers/databases",
"location": "[resourceGroup().location]",
"apiVersion": "2014-04-01-preview",
"copy": {
"count": 3,
"name": "sql-copy"
},
"dependsOn": [ "[resourceId('Microsoft.Sql/servers', variables('brandosqlName'))]" ],
"tags": {
"displayName": "copysqldatabase2"
},
"properties": {
"collation": "[parameters('copysqldatabase2Collation')]",
"edition": "[parameters('copysqldatabase2Edition')]",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "[parameters('copysqldatabase2RequestedServiceObjectiveName')]"
}
},
{
"name": "[concat(variables('brandosqlName'), '/', parameters('org')[copyIndex()],'/','aaaa')]",
"type": "Microsoft.Sql/servers/databases/extensions",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ "sql-copy" ],
"tags": {
"displayName": "copy3"
},
"copy": {
"name": "sql-copy2",
"count": 3
},
"properties": {
"storageKeyType": "[parameters('copy2StorageKeyType')]",
"storageKey": "[parameters('copy2StorageKey')]",
"storageUri": "[parameters('copy2StorageUri')]",
"administratorLogin": "[parameters('copy2AdministratorLogin')]",
"administratorLoginPassword": "[parameters('copy2AdministratorLoginPassword')]",
"operationMode": "Import"
}
}
],
"outputs": {}
}
Result:
I have also test your template, I found there are something wrong with your storage url in import extension. I changed it with primary storage key and url. It works well.
Template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "eastasia"
},
"sqlAdminUsername": {
"type": "string"
},
"sqlAdminPassword": {
"type": "string"
},
"sqlServerName": {
"type": "string"
},
"sqlDatabaseNames": {
"type": "array",
"defaultValue": [
"CustomersDB",
"WideWorldImporters-Standard"
]
},
"sqlEdition": {
"type": "string",
"defaultValue": "Standard"
},
"sqlRequestedServiceObjectiveName": {
"type": "string",
"defaultValue": "S2"
},
"sqlMaxSizeBytes": {
"type": "string",
"defaultValue": "268435456000"
},
"publicIP": {
"type": "string"
},
"copy2StorageKeyType": {
"type": "string",
"minLength": 1
},
"copy2StorageKey": {
"type": "string"
},
"copy2StorageUri": {
"type": "string",
"minLength": 1
}
},
"variables": {
"storageKeyType": "SharedAccessKey",
"collation": "SQL_Latin1_General_CP1_CI_AS"
},
"resources": [
{
"name": "[parameters('sqlServerName')]",
"type": "Microsoft.Sql/servers",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('sqlAdminUsername')]",
"administratorLoginPassword": "[parameters('sqlAdminPassword')]",
"version": "12.0"
},
"resources": [
{
"name": "AllowAllWindowsAzureIps",
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
}
},
{
"name": "Allow_Remote_SSMS",
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', parameters('sqlServerName'))]"
],
"properties": {
"startIpAddress": "[parameters('publicIP')]",
"endIpAddress": "[parameters('publicIP')]"
}
}
]
},
{
"name": "[concat(parameters('sqlServerName'), '/', parameters('sqlDatabaseNames')[copyIndex()])]",
"type": "Microsoft.Sql/servers/databases",
"location": "[parameters('location')]",
"apiVersion": "2014-04-01-preview",
"copy": {
"count": "[length(parameters('sqlDatabaseNames'))]",
"name": "sql-copy"
},
"dependsOn": [ "[resourceId('Microsoft.Sql/servers/', parameters('sqlServerName'))]" ],
"properties": {
"collation": "[variables('collation')]",
"edition": "[parameters('sqlEdition')]",
"maxSizeBytes": "[parameters('sqlMaxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('sqlRequestedServiceObjectiveName')]"
}
},
{
"name": "[concat(parameters('sqlServerName'), '/', parameters('sqlDatabaseNames')[copyIndex()],'/','import')]",
"type": "Microsoft.Sql/servers/databases/extensions",
"apiVersion": "2014-04-01-preview",
"dependsOn": [ "sql-copy" ],
"copy": {
"name": "sql-import",
"count": "[length(parameters('sqlDatabaseNames'))]"
},
"properties": {
"storageKeyType": "[parameters('copy2StorageKeyType')]",
"storageKey": "[parameters('copy2StorageKey')]",
"storageUri": "[parameters('copy2StorageUri')]",
"administratorLogin": "[parameters('sqlAdminUsername')]",
"administratorLoginPassword": "[parameters('sqlAdminPassword')]",
"operationMode": "Import"
}
}
]
}
Result:

Resources