0

I have an ARM template, which I will be using it to deploy resources (Mentioned as in Azure Portal) via Azure DevOps Pipeline. These ARM templates were created using my Dev Subscription. If I need to use this same ARM template to move to production, I need to manually update the subscription id etc in the ARM template and then run the respective pipelines. Is there any way to automate this manual updation process in ARM template.

I have tried using File Transform Agent job available under Azure DevOps Release pipeline. But since the values are available inside nested loops of ARM templates, it failed. Is there any PowerShell script that will be suitable for this process of updating values.

I don't want to manually update the ids under the ARM Template. Instead, I want to update it automatically.

IT_Guy
  • 79
  • 2
  • 11
  • i'm not sure how that (`encodeURIcomponent`) works exactly, but `replace()` function might work together with the parameters file – 4c74356b41 Sep 13 '19 at 08:19

2 Answers2

0

Instead of hard coding in ARM templates you can use parameters file. For dev and prod you can have separate files and while deploying pass ARM Template along with parameter file whichever is required.

You can use AKV (Azure Key Vault) to access your subscription details in parameter file

subscription().subscriptionid will get you the details

  • You can use AKV (Azure Key Vault) to access your subscription details – Akhilesh Kumar Sep 13 '19 at 08:08
  • Few ids such Subscription Id doesn't available in Parameter.json. Only few important variables were available under Parameter.json. Usually, the Resource Id will not get populated under Parameter.json. In my case need to update a part of resource id. For Example value "x" : "id": "/subscriptions/xxx-xxx-xxx-xxx/providers/Microsoft.Web/locations/centralus/managedApis/azuredatalake" – IT_Guy Sep 13 '19 at 08:12
  • Try this under variables of your ARM Template "[concat('/subscriptions/',subscription().subscriptionid,'/resourceGroups/@{encodeURIComponent('TestResourceGroup')}/providers/Microsoft.DataFactory/factories')] – Akhilesh Kumar Oct 18 '19 at 09:09
0

Set Json Property task might help to set the property with specific value.

First in the marketplace search for "set Json property" task and install it for your organization.

enter image description here

Then you can set the property path and the value accordingly. check here for detail usage

enter image description here

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43