使用Azure DevOps Git配置的DataFactory的Azure ARM模板部署模板、DevOps、Azure、Git

2023-09-03 13:47:36 作者:该玩的年纪却动了心

我正在尝试部署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": []
          }
        ]
}

推荐答案

使用Azure DevOps持续集成GitHub项目

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

"repoConfiguration":"[Variables(‘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')]"
            }
        }
    ]
}
 
精彩推荐
图片推荐