首页 > 解决方案 > 使用 Azure DevOps Git 配置的 DataFactory 的 Azure ARM 模板部署

问题描述

我正在尝试部署 Azure DataFactory 资源并将其配置为使用 Azure DevOps Git 进行源代码控制。Azure Devops 组织、存储库和协作分支都存在。

当我部署模板时,会创建 DataFactory 资源,但它没有连接到源代码控制。我的帐户可以访问 Azure DevOps 组织,我可以手动连接源代码控制

我正在使用以下模板:

{
    "contentVersion": "1.0.0.0",
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "variables": {
        "repoConfiguration": {
            "accountName": "my-account",
            "collaborationBranch": "dev",
            "lastCommitId": "",
            "projectName": "Azure",
            "repositoryName": "golaat",
            "rootFolder": "/",
            "tenantId": "",
            "type": "FactoryVSTSConfiguration"
        }
    },
    "resources": [
        {
            "type": "Microsoft.DataFactory/factories",
            "apiVersion": "2018-06-01",
            "name": "my-resource-golaat8-adf",
            "location": "eastus2",
            "identity": {
              "type": "SystemAssigned"
            },
            "properties": {
              "repoConfiguration": "[variables('repoConfiguration')]"
            },
            "resources": []
          }
        ]
}

标签: gitazureazure-resource-managerazure-data-factory-2azure-deployment

解决方案


您需要从变量中获取 repoConfiguration,如下所示:

“repoConfiguration”:“[变量('repoConfiguration')]”

不要错过方括号。我在我身边尝试并取得了成功。

{
    "$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')]"
            }
        }
    ]
}

推荐阅读