admin管理员组

文章数量:1208153

I want to override the parameters of an object or array within the Arm Template. How can I pass the new values to the template from the task?

I use the following task:

    - task: AzureResourceManagerTemplateDeployment@3
      displayName: "Create Container App"
      inputs:
         deploymentScope: 'Resource Group'
         azureResourceManagerConnection: '$(serviceConnection)'
         subscriptionId: '$(SubscriptionID)'
         action: 'Create Or Update Resource Group'
         resourceGroupName: '$(ResourceGroup)'
         location: 'West Europe'
         templateLocation: 'Linked artifact'
         csmFile: '$(Pipeline.Workspace)/drop/armtemplates/container_deployment.json'
         csmParametersFile: '$(Pipeline.Workspace)/drop/armtemplates/container_parameters.json'
         deploymentMode: 'Incremental'
         overrideParameters: '-SubscriptionId $(SubscriptionID) -containers $(ContainerAppName) -ResourceGroup $(ResourceGroup) -BuildID $($(Build.BuildId)) -RegistriesServer $(RegistriesServer) -RepositoryAppName $(RepositoryAppName) -ContainerAppEnvironment $(ContainerAppEnvironment) -UserIdentityName $(UserIdentityName)'
      continueOnError: false

In the example task above, I don't know how to pass a new value to the parameter (containers -> value -> name) in the parameter.json file which has the parameter (as an object) containers (see below). I need to change the name and image values. How can I override those parameters? How do I pass the new value?

        "containers": {
        "value": [
            {
                "name": "$(ContainerAppName)",
                "image": "$(containerAppImageName)",
                "command": [],
                "args": [],
                "resources": {
                    "cpu": 0.5,
                    "memory": "1Gi"
                }
            }
        ]
    }

I was not able to find the correct solution.

I am using AzureResourceManagerTemplateDeployment@3 as the deployment task.

The post about How to pass azure pipeline variables is not the same as my question. I need to know how to override the parameter within an object or array. I hope that this is clear.

I want to override the parameters of an object or array within the Arm Template. How can I pass the new values to the template from the task?

I use the following task:

    - task: AzureResourceManagerTemplateDeployment@3
      displayName: "Create Container App"
      inputs:
         deploymentScope: 'Resource Group'
         azureResourceManagerConnection: '$(serviceConnection)'
         subscriptionId: '$(SubscriptionID)'
         action: 'Create Or Update Resource Group'
         resourceGroupName: '$(ResourceGroup)'
         location: 'West Europe'
         templateLocation: 'Linked artifact'
         csmFile: '$(Pipeline.Workspace)/drop/armtemplates/container_deployment.json'
         csmParametersFile: '$(Pipeline.Workspace)/drop/armtemplates/container_parameters.json'
         deploymentMode: 'Incremental'
         overrideParameters: '-SubscriptionId $(SubscriptionID) -containers $(ContainerAppName) -ResourceGroup $(ResourceGroup) -BuildID $($(Build.BuildId)) -RegistriesServer $(RegistriesServer) -RepositoryAppName $(RepositoryAppName) -ContainerAppEnvironment $(ContainerAppEnvironment) -UserIdentityName $(UserIdentityName)'
      continueOnError: false

In the example task above, I don't know how to pass a new value to the parameter (containers -> value -> name) in the parameter.json file which has the parameter (as an object) containers (see below). I need to change the name and image values. How can I override those parameters? How do I pass the new value?

        "containers": {
        "value": [
            {
                "name": "$(ContainerAppName)",
                "image": "$(containerAppImageName)",
                "command": [],
                "args": [],
                "resources": {
                    "cpu": 0.5,
                    "memory": "1Gi"
                }
            }
        ]
    }

I was not able to find the correct solution.

I am using AzureResourceManagerTemplateDeployment@3 as the deployment task.

The post about How to pass azure pipeline variables is not the same as my question. I need to know how to override the parameter within an object or array. I hope that this is clear.

Share Improve this question edited Jan 20 at 19:49 Sergio asked Jan 20 at 15:14 SergioSergio 1451 silver badge15 bronze badges 4
  • This question is similar to: How to pass azure-pipelines.yml variables to ARM templates with AzureResourceManagerTemplateDeployment. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – Rui Jarimba Commented Jan 20 at 15:23
  • @rui-jarimba in my opinion it is not the same. I know that I can override the parameters with overrideParameters options and how I can import the key vault etc. I need to know how I can override the parameters which are defined as an array in the arm template. How do I have to define the parameter in the overrideParameter: -Parametername $(ValueToPass) – Sergio Commented Jan 20 at 19:39
  • 1 Please edit the question and add more details, e.g. the pipeline task(s) and the values you're trying to set. – Rui Jarimba Commented Jan 20 at 19:46
  • @rui-jarimba done. thank you – Sergio Commented Jan 20 at 19:50
Add a comment  | 

1 Answer 1

Reset to default 1

Please check the task doc for overrideParamters below:

The trick is you can classic UI task to help find the correct definition.

Select template.json and paramter.json, then you can click ... button to override parameters, it will pop up the parameters and it's default value, you can use variables for the value then.

You can see the yaml by clicking the View Yaml button, then copy the overrideParamters to your real yaml.

本文标签: azure devopsHow to override the object and array parameters in the Arm templateStack Overflow