TL;DR
The following line works fine as part of an ARM script ran in an Azure DevOps ARM Template Deployment task but, when ran from PowerShell, it fails to pull the subscription and the resource group.
"serverFarmId": "[concat('/subscriptions/', subscription(), '/resourcegroups/', resourceGroup(), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
how can I set the subscription and resource group variables so the ARM functions can pull the values?
P.S. It's ok If I have to first get them and then set them manually for the script to consume, as long as I can use the same script for DevOps and PowerShell.
Here's the resources section of the template which, again, when deployed from a pipeline it pulls the subscription and the resource group from whatever is set in the task parameters.
"resources": [
{
"apiVersion": "2018-11-01",
"name": "[parameters('name')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"tags": {},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
],
"properties": {
"name": "[parameters('name')]",
"siteConfig": {
"metadata": [
{
"name": "CURRENT_STACK",
"value": "[parameters('currentStack')]"
}
]
},
"serverFarmId": "[concat('/subscriptions/', subscription(), '/resourcegroups/', resourceGroup(), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"clientAffinityEnabled": true
}
},
{
"apiVersion": "2018-11-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"kind": "",
"tags": {},
"dependsOn": [],
"properties": {
"name": "[parameters('hostingPlanName')]"
},
"sku": {
"Tier": "[parameters('sku')]",
"Name": "[parameters('skuCode')]"
}
}
]
.subscriptionIdand.namegot it running from powershell.