【发布时间】:2022-05-12 21:33:23
【问题描述】:
我希望在存储帐户上启用静态站点托管,该帐户由 Azure DevOps 管道中的 Azure 资源管理器 (ARM) 模板创建,但无法让 jq 解析 ARM 输出变量。
第 1 步:创建资源组的 Azure DevOps 任务的 YML
- task: AzureResourceGroupDeployment@2
inputs:
azureSubscription: 'AzureSubscription'
action: 'Create Or Update Resource Group'
resourceGroupName: 'vue-demo-app'
location: 'West Europe'
templateLocation: 'Linked artifact'
csmFile: '$(Build.ArtifactStagingDirectory)/infra/infra.json'
csmParametersFile: '$(Build.ArtifactStagingDirectory)/infra/env-arm-params-default.json'
deploymentMode: 'Incremental'
deploymentOutputs: 'appstoragename'
displayName: 'Create or update resource group'
日志显示如下:
##[debug]set appstoragename={"appstoragename":{"type":"String","value":"demoappstaticstore"}}
所以此时,有一个有效 JSON 值返回给 Azure DevOps。到目前为止,一切顺利。
第 2 步:尝试在存储帐户上启用静态网站托管的 Azure DevOps 任务
- task: AzureCLI@1
inputs:
azureSubscription: 'AzureSubscription'
scriptLocation: 'inlineScript'
inlineScript: |
echo "Enabling static website hosting on the storage account"
SA_NAME=$(appstoragename) | jq -r '.appstoragename'
echo "Script input argument is: $(appstoragename)"
echo "Parsed storage account name is: $SA_NAME"
az storage blob service-properties update --account-name $SA_NAME --static-website --index-document index.html
日志显示如下:
Enabling static website hosting on the storage account
Script input argument is: {appstoragename:{type:String,value:jvwdemoappstaticstore}}
Parsed storage account name is:
恕我直言,问题是我“丢失”了 $(appstoragename) 中的引号,我需要它们,因为我认为 jq 不喜欢它们不存在的事实。
如何防止这些引号消失?
【问题讨论】:
标签: bash azure-devops azure-pipelines