简体   繁体   中英

How to reference an ARM Template hosted in GitHub in an Azure DevOps Pipeline?

I have this simple pipeline that migrates my DataFactory code from one lane to another patterned after Microsoft's recommendations . Here it is:

steps:
- task: AzureResourceManagerTemplateDeployment@3
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: '{connectionName}'
    subscriptionId: '{subscriptionId}'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'default-rg'
    location: 'East US'
    templateLocation: 'URL of the file'
    csmFileLink: 'https://raw.githubusercontent.com/{OrgName}/{RepoName}/adf_publish/{folder}/ARMTemplateForFactory.json?token=GHSAT0AAAAAA*************************'
    csmParametersFileLink: 'https://raw.githubusercontent.com/{OrgName}/{RepoName}/adf_publish/{folder}/ARMTemplateParametersForFactory.json?token=GHSAT0AAAAAA*************************'
    overrideParameters: '-factoryName "{new factory name}"'
    deploymentMode: 'Incremental'

This code succeeds, but on line 10 I had to specify "URL of the file" and in line 12 and 13, I provide the raw url including a token parameter to allow access. I would like to instead link my GitHub repo and point to the files there. I can't figure out how to do so. Can anyone help?

Here is where I am so far. I added 1-7 to reference the GitHub repo where the files live. They exist on the "adf_publish" branch. Line 18 I changed to the "Linked Artifact". Line 19 and 20 is where I want to reference my files, but not sure what the syntax should be.

resources:
  repositories:
  - repository: {RepoName}
    type: github
    name: {OrgName}/{RepoName}
    endpoint: {ServiceConnectionName}
    ref: adf_publish

steps:
- task: AzureResourceManagerTemplateDeployment@3
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: '{ConnectionName}'
    subscriptionId: '{subscriptionId}'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'default-rg'
    location: 'East US'
    templateLocation: 'Linked artifact'
    csmFile: '??'
    csmParametersFile: '??'
    overrideParameters: '-factoryName "{new factory name}"'
    deploymentMode: 'Incremental'

I got it to work using this code:

resources:
  repositories:
  - repository: adf_publish
    type: github
    name: {OrgName}/{RepoName}
    endpoint: {ServiceConnectionName}
    ref: adf_publish
steps:
- checkout: self
  path: main
- checkout: adf_publish
  path: adf
- task: AzureResourceManagerTemplateDeployment@3
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: {ConnectionName}
    subscriptionId: '{subscriptionId}'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'default-rg'
    location: 'East US'
    templateLocation: 'Linked artifact'
    csmFile: '$(Agent.BuildDirectory)/adf/{data factory name}/ARMTemplateForFactory.json'
    csmParametersFile: '$(Agent.BuildDirectory)/adf/{data factory name}/ARMTemplateParametersForFactory.json'
    overrideParameters: '-factoryName "{new factory name}"'
    deploymentMode: 'Incremental'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM