Monday, October 12, 2020

Deploy Data Factory from GIT to Azure with ARM Template

You may have noticed the export feature on Azure resource groups don’t like too much the Data Factory. We can’t completely export a Data Factory as an ARM template, it fails.

Probably you know you don’t need to care about this too much. You can link the data factory with a github repo and get source code versioning control. The versioning control is, after all, even better than a simple export to an ARM template.

Even so, we will still need an ARM template to deploy this data factory to another azure environment when we would like so. The good news is this template is not only easy, but absolutely the same for any data factory we would like, because it just need to point to a github repo and all the data factory code will come from there.

The main part of the ARM template is the resource definition and the secret of the data factory resource definition is how to define a data factory already linked with github. Take a look:

{
   "resources": [
      {
         "type": "Microsoft.DataFactory/factories",
         "apiVersion": "[parameters('apiVersion')]",
         "name": "[parameters('name')]",
         "location": "[parameters('location')]",
         "identity": {
            "type": "SystemAssigned"
         },
         "properties": {
            "repoConfiguration": "[variables('repoConfiguration')]"
         }
      }
   ]
}

It’s a regular resource definition, except by the properties: That’s the secret. We set the property repoConfiguration to an array with all github configurations needed for the data factory.

As you may notice, this property is making reference to a variable. As a result, we need to set this variable before the resources element.

{
   "variables": {
      "repoConfiguration": {
         "type": "FactoryVSTSConfiguration",
         "accountName": "[parameters('gitAccountName')]",
         "repositoryName": "[parameters('gitRepositoryName')]",
         "collaborationBranch": "[parameters('gitBranchName')]",
         "rootFolder": "[parameters('gitRootFolder')]",
         "projectName": "[parameters('gitProjectName')]"
      }
   }
}

All the github configuration properties are parameterized. Therefore, when deploying a data factory we will only this same ARM template and fill the parameters values.

The final ARM template will be this:

{
   "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
   "contentVersion": "1.0.0.0",
   "parameters": {
      "name": {
         "defaultValue": "myv2datafactory",
         "type": "String"
      },
      "location": {
         "defaultValue": "East US",
         "type": "String"
      },
      "apiVersion": {
         "defaultValue": "2018-06-01",
         "type": "String"
      },
      "gitAccountName": {
         "type": "String"
      },
      "gitRepositoryName": {
         "type": "String"
      },
      "gitBranchName": {
         "defaultValue": "master",
         "type": "String"
      },
      "gitRootFolder": {
         "defaultValue": "/",
         "type": "String"
      },
      "gitProjectName": {
         "type": "String"
      }
   },
   "variables": {
      "repoConfiguration": {
         "type": "FactoryVSTSConfiguration",
         "accountName": "[parameters('gitAccountName')]",
         "repositoryName": "[parameters('gitRepositoryName')]",
         "collaborationBranch": "[parameters('gitBranchName')]",
         "rootFolder": "[parameters('gitRootFolder')]",
         "projectName": "[parameters('gitProjectName')]"
      }
   },
   "resources": [
      {
         "type": "Microsoft.DataFactory/factories",
         "apiVersion": "[parameters('apiVersion')]",
         "name": "[parameters('name')]",
         "location": "[parameters('location')]",
         "identity": {
            "type": "SystemAssigned"
         },
         "properties": {
            "repoConfiguration": "[variables('repoConfiguration')]"
         }
      }
   ]
}

 

 

 

The post Deploy Data Factory from GIT to Azure with ARM Template appeared first on Simple Talk.



from Simple Talk https://ift.tt/2GWUVro
via

No comments:

Post a Comment