skip to Main Content

I am passing some override parameters to my Data Factory ARM template deployment step in an Azure DevOps yaml file and one global parameter in particular is specified as an ‘int’ type within the generated ARM template.

enter image description here

When I attempt to pass the override parameter from a variable group, Azure DevOps keeps changing it to a string instead of keeping it as an int type resulting in an error within the pipeline.

enter image description here

I’ve tried a few things listed below but none have worked.

Deploy task:

  - task: AzureResourceManagerTemplateDeployment@3
    displayName: ARM Template Deployment
    inputs:
      azureResourceManagerConnection: 
      subscriptionId: 
      resourceGroupName: 
      location:
      csmFile:
      csmParametersFile:
      overrideParameters: >
        -factoryName ${{ parameters.dataFactoryName }}
        ${{ parameters.overrideParameters }}

Variable in the variable group:

enter image description here

Doesn’t work:

variables:
  - group: test-group

...

    jobs:
      - template: datafactory/create-release.yml@templates
        parameters:
          dataFactoryName: asdfasdf
          overrideParameters: >
            -default_properties_LogoAssetId_value $(default_properties_LogoAssetId_value_Stage)

Doesn’t work:

variables:
  - group: test-group

...

    jobs:
      - template: datafactory/create-release.yml@templates
        parameters:
          dataFactoryName: asdfasdf
          overrideParameters: >
            -default_properties_LogoAssetId_value "[int(parameters($(default_properties_LogoAssetId_value_Stage)))]"

EDIT:

Here is a snippet of datafactory/create-release.yml

I think the issue is that I set it as a "string" type. However, I don’t know an alternative way to handle passing the override parameters as a mixture of string and int values.

  - name: overrideParameters
    type: string


jobs:
  - deployment: Deploy
    displayName: Deploy ARM Template
    environment: Prod
    pool:
      vmImage: ubuntu-latest
    strategy:
      runOnce:
        deploy:
          steps:
            - template: steps/step-arm-template-deploy.yml
              parameters:
                subscriptionId: ${{ parameters.subscriptionId }}
                targetResourceGroupName: ${{ parameters.targetResourceGroupName }}
                targetDataFactorylocation: ${{ parameters.targetDataFactorylocation }}
                targetDataFactoryName: ${{ parameters.targetDataFactoryName }}
                overrideParameters: ${{ parameters.overrideParameters }}

2

Answers


  1. Chosen as BEST ANSWER

    My workaround for now is casting my parameter in DataFactory as an int like this

    @int(pipeline().globalParameters.LogoAssetId)

    While not ideal, it allows me to continue to use my template as-is.


  2. I created one sample parameter with type set to int and added it in my azure repository like below:-

    I have referred the ADF ARM template from this MS Document

    enter image description here

    "Default_properties_log": {
          "type" : "int",
          "defaultvalue" : 1234
    

    And I used output method at the end of my ARM template like below:-

    enter image description here

    "outputs": { 
        "parametertested" : {"type": "int",
        "value": "[parameters('Default_properties_log')]"}
        }
    

    When I added the below value in my release pipeline override parameter, I received the same error code as yours:-

    Error:-

    enter image description here

    ##[error]Deployment template validation failed: 'The provided value for the template parameter 'Default_properties_log' is not valid. Expected a value of type 'Integer', but received a value of type 'String'. Please see [https://aka.ms/arm-create-parameter-file](https://aka.ms/arm-create-parameter-file) for usage details.'.
    

    As In my ARM file I have mentioned the type as int but I was passing value in the format below, I received the error above:-

    $(int(Default_properties_log))

    enter image description here

    But when I use "12345" or 1234 both will work the error did not appear and the ADF with storage account got deployed successfully in my Azure Portal, Refer below:-

    enter image description here

    My release yaml pipeline script:-

    steps:
    - task: AzureResourceManagerTemplateDeployment@3
      displayName: 'ARM Template deployment: Resource Group scope'
      inputs:
        azureResourceManagerConnection: 'xxxx'
        subscriptionId: 'xxxxxd6-b4fd-e2b6e97cb2a7'
        resourceGroupName: siliconrg421rg09
        location: 'Australia East'
        csmFile: azdeploy.json
        overrideParameters: '-dataFactoryName "xxx" -location "AustraliaEast" -Default_properties_log "1234" -storageAccountName "xxxx" -blobContainerName "[format(''blob{0}'', uniqueString(resourceGroup().id))]"'
    

    Output:-

    enter image description here

    One alternative is to create parameters.json file and add all your ARM template parameters inside it and then change the type in parameters.json and override the value in your release pipeline. Make sure the type you specify whether int or string should match the value. As, Override parameter feature will only change the value of the parameter not its type. It will read the type from your ARM template json or parameters.json.

    My parameters.json file sample:-

    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "default_properties_LogAssetId_value": {
                "type": "int",
                "value": 12345
            }
        }
    }
    

    enter image description here

    enter image description here

    Release.yaml with parameters.json file:-

    steps:
    - task: AzureResourceManagerTemplateDeployment@3
      displayName: 'ARM Template deployment: Resource Group scope'
      inputs:
        azureResourceManagerConnection: 'xxxx'
        subscriptionId: 'xxxxx-b4fd-e2b6e97cb2a7'
        resourceGroupName: siliconrg421rg09
        location: 'Australia East'
        csmFile: azdeploy.json
        csmParametersFile: parameters.json
        overrideParameters: '-dataFactoryName "xxxx" -location "AustraliaEast" -Default_properties_log "1234" -storageAccountName "xxxx" -blobContainerName "[format(''blob{0}'', uniqueString(resourceGroup().id))]" -default_properties_LogAssetId_value 0987'
    

    Reference:-

    AzureResourceManagerTemplateDeployment@3 – ARM template deployment v3 task | Microsoft Learn

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search