9
votes

I am trying to create my Azure DevOps release pipeline for Azure Data Factory.

I have followed the rather cryptic guide from Microsoft (https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment ) regarding adding additional parameters to the ARM template that gets generated when you do a publish (https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment#use-custom-parameters-with-the-resource-manager-template )

Created a arm-template-parameters-definition.json file in the route of the master branch. When I do a publish, the ARMTemplateParametersForFactory.json in the adf_publish branch remains completely unchanged. I have tried many configurations.

I have defined some Pipeline Parameters in Data Factory and want them to be configurable in my deployment pipeline. Seems like an obvious requirement to me.

Have I missed something fundamental? Help please!

The JSON is as follows:

{
    "Microsoft.DataFactory/factories/pipelines": {
        "*": {
            "properties": {
                "parameters": {
                        "*": "="                
                }
            }
        }
    },
    "Microsoft.DataFactory/factories/integrationRuntimes": {
        "*": "="
    },
    "Microsoft.DataFactory/factories/triggers": {},
    "Microsoft.DataFactory/factories/linkedServices": {},
    "Microsoft.DataFactory/factories/datasets": {}
}
5
why do you think it must change? it shouldnt. it should use these parameters to deploy whatever you need. its not going to update contents of that file in the repo (why would it?)4c74356b41
@4c74356b41 Yes it should when you publish and it does, but not consistently. I suggest you read the link posted in the question.NER1808

5 Answers

13
votes

I've been struggling with this for a few days and did not found a lot of info, so here what I've found out. You have to put the arm-template-parameters-definition.json in the configured root folder of your collaboration branch:

data factory git settings

So in my example, it has to look like this:

arm-template-parameters-definition.json

If you work in a separate branch, you can test your configuration by downloading the arm templates from the data factory. When you make a change in the parameters-definition you have to reload your browser screen (f5) to refresh the configuration. Data factory download arm template

If you really want to parameterize all of the parameters in all of the pipelines, the following should work:

"Microsoft.DataFactory/factories/pipelines": {
    "properties": {
        "parameters":{
            "*":{
                "defaultValue":"="
            }
        }
    }
}

I prefer specifying the parameters that I want to parameterize:

"Microsoft.DataFactory/factories/pipelines": {
    "properties": {
        "parameters":{
            "LogicApp_RemoveFileFromADLSURL":{
                "defaultValue":"=:-LogicApp_RemoveFileFromADLSURL:"
            },
            "LogicApp_RemoveBlob":{
                "defaultValue":"=:-LogicApp_RemoveBlob:"
            }
        }
    }
}
5
votes

Just to clarify on top of Simon's great answer. If you have non standard git hierarchy (i.e. you move the root to a sub-folder like I have done below with "Source"), it can be confusing when the doc refers to the "repo root". Hopefully this diagram helps.

enter image description here

2
votes

You've got the right idea, but the arm-template-parameters-definition.json file needs to follow the hierarchy of the element you want to parameterize.

Here is my pipeline activity I want to parameterize. The "url" should change based on the environment it's deployed in

{
    "name": "[concat(parameters('factoryName'), '/ExecuteSPForNetPriceExpiringContractsReport')]",
    "type": "Microsoft.DataFactory/factories/pipelines",
    "apiVersion": "2018-06-01",
    "properties": {
        "description": "",
        "activities": [
            {
                "name": "NetPriceExpiringContractsReport",
                "description": "Passing values to the Logic App to generate the CSV file.",
                "type": "WebActivity",
                "typeProperties": {
                    "url": "[parameters('ExecuteSPForNetPriceExpiringContractsReport_properties_1_typeProperties')]",
                    "method": "POST",
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    "body": {
                        "resultSet": "@activity('NetPriceExpiringContractsReportLookup').output"
                    }
                }
            }
        ]
    }
}

Here is the arm-template-parameters-definition.json file that turns that URL into a parameter.

{
   "Microsoft.DataFactory/factories/pipelines": {
        "properties": {
            "activities": [{
                "typeProperties": {
                    "url": "-::string"
                }
            }]
        }
    },
    "Microsoft.DataFactory/factories/integrationRuntimes": {},
    "Microsoft.DataFactory/factories/triggers": {},
    "Microsoft.DataFactory/factories/linkedServices": {
        "*": "="
    },
    "Microsoft.DataFactory/factories/datasets": {
        "*": "="
    }
}

So basically in the pipelines of the ARM template, it looks for properties -> activities -> typeProperties -> url in the JSON and parameterizes it.

0
votes

Here are the necessary steps to clear up confusion:

  1. Add the arm-template-parameters-definition.json to your master branch.
  2. Close and re-open your Dev ADF portal
  3. Do a new Publish

Your ARMTemplateParametersForFactory.json will then be updated.

0
votes

I have experienced similar problems with the ARMTemplateParametersForFactory.json file not being updated whenever I publish and have changed the arm-template-parameters-definition.json.

I figured that I can force update the Publish branch by doing the following:

  1. Update the custom parameter definition file as you wish.
  2. Delete ARMTemplateParametersForFactory.json from the Publish branch.
  3. Refresh (F5) the Data Factory portal.
  4. Publish.

The easiest way to validate your custom parameter .json syntax seems to be by exporting the ARM template, just as Simon mentioned.