I am using Azure Resource Group Deployment task in Azure Devops. Some of the Override template parameters include the SubscriptionID.
-virtualNetworkId /subscriptions/53614803-d327-4397-bf55-8dedcc24be0d/resourceGroups/$(resourceGroup)/providers/Microsoft.Network/virtualNetworks/vnet
Is there a was to use the SubsciptionID used in the Azure subscription connection ?
Reason: The subscriptionId needed to be known in the build pipeline. This also solves the uniqueString template issue, where we need to know the uniqueString, but powershell does not have a way to tell you.
My deployments are being built to run in any ResourceGroup in different Subscriptions. I am deploying several VM's using the ARM template generated creating one VM in the portal. One of the parameters embedded the subscription Id as shown in question. Because of how the variables are calculated inside the template built by the portal, [subscription.SubscriptionId] was not going to work:
"variables": {
"vnetId": "[parameters('virtualNetworkId')]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
It ends up at run time as:
/subscriptions/$(subscription().subscriptionid)/resourceGroups/Dev1/providers/Microsoft.Network/virtualNetworks/vnet/subnets/default
I do not want to edit the template, as I will need to make some adjustments to future deployments, and will likely use the portal to make a new template. The subscriptionId needed to be known in the build pipeline. This also solves the uniqueString template issue, where we need to know the uniqueString, but powershell does not have a way to tell you.