我创建了两个模板——一个用于获取和设置一些配置,例如区域名称,另一个用于部署。我正在尝试将配置模板任务中设置的变量用作部署模板的参数输入。有没有这样做的实际方法?
我的配置模板:
steps:
- task: AzureCLI@2
name: Config
displayName: Get Config and Generate Variables
inputs:
azureSubscription: '$(Subscription)'
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
Environment="prod"
echo "##vso[task.setvariable variable=Environment;isOutput=true]prod"
echo "##vso[task.setvariable variable=EastName;isOutput=true]$(AppNamePrefix)-$Environment-eastus"
echo "##vso[task.setvariable variable=East2Name;isOutput=true]$(AppNamePrefix)-$Environment-eastus2"
echo "##vso[task.setvariable variable=CentralName;isOutput=true]$(AppNamePrefix)-$Environment-centralus"
echo "##vso[task.setvariable variable=WestName;isOutput=true]$(AppNamePrefix)-$Environment-westus"
我的部署模板如下所示:
parameters:
- name: artifactName
type: string
default: MyBuildOutputs
- name: appFullName
type: string
- name: condition
type: boolean
default: true
steps:
- task: AzureFunctionApp@1
condition: ${{ parameters.condition }}
displayName: 'Production deploy'
inputs:
azureSubscription: '$(Subscription)'
appType: 'functionApp'
appName: ${{ parameters.appFullName }}
package: '$(System.ArtifactsDirectory)/${{ parameters.artifactName }}/$(Build.BuildId).zip'
deploymentMethod: 'auto'
我的舞台看起来像这样(去掉了不必要的位):
- template: ../../tasks/azure/getConfig.yml
- template: ../../tasks/azure/deployToFA.yml
parameters:
appFullName: $(EastName)
我尝试了以下方法appFullName: <name>
:
$(EastName)
${{ EastName }}
$[ EastName ]
$EastName
但是,可悲的是,这些似乎都不起作用,因为它们都被作为文字拉入。有没有办法做到这一点?我已经看到了使用方法,dependsOn
但我不希望两个模板之间存在隐藏的依赖关系(如果可能的话)