adan11
adan11

Reputation: 787

Azure - ARM Template deployment

I'm trying to automate some deployments of Resources in Azure. To get the templates, I go to the resource in Azure and select 'Export Template' to get the relevant JSON files. I then try to deploy these into a new environment by running:

az deployment group create --resource-group test-rg --template-file arm_templates\test-rg\template.json --mode=Complete

This seems to work fine, the error I am getting when deploying these is:

[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"PropertyIsReadonly\",\r\n    \"message\": \"The property 'provisioningState' is readonly.\"\r\n  }\r\n}"}]}}

This is because when exporting my templates, there is a filed called provisioningState which is set to "Succeeded". Is there a way I can ignore these readOnly fields when deploying these templates instead of having to manually remove them from the template JSON's?

example ARM template:

{
      "type": "Microsoft.CognitiveServices/accounts/privateEndpointConnections",
      "apiVersion": "2021-10-01",
      "name": "[concat(parameters('accounts_test-cs-_aue_cscv03_dev_name'), '/', parameters('accounts_test-cs_cscv03_dev_name'), '.300a127f-60fa-4806-99999999999')]",
      "location": "australiaeast",
      "dependsOn": [
        "[resourceId('Microsoft.CognitiveServices/accounts', parameters('accounts_test-cs_aue_cscv03_dev_name'))]"
      ],
      "properties": {
        "privateEndpoint": {},
        "groupIds": ["account"],
        "privateLinkServiceConnectionState": {
          "status": "Approved",
          "description": "Approved",
          "actionsRequired": "None"
        },
        "provisioningState": "Succeeded"
      }
    },

Thanks in advance,

Upvotes: 1

Views: 608

Answers (1)

maras2002
maras2002

Reputation: 321

You have to ignore it. Proper JSON for ARM for this type is documented here: https://learn.microsoft.com/en-us/azure/templates/microsoft.cognitiveservices/accounts/privateendpointconnections?tabs=json

{
  "type": "Microsoft.CognitiveServices/accounts/privateEndpointConnections",
  "apiVersion": "2021-10-01",
  "name": "string",
  "location": "string",
  "properties": {
    "groupIds": [ "string" ],
    "privateEndpoint": {},
    "privateLinkServiceConnectionState": {
      "actionsRequired": "string",
      "description": "string",
      "status": "string"
    }
  }
}

Upvotes: 1

Related Questions