[英]Deploy Appsettings for Azure function app using Azure Devops and Yaml and Variable group
Is there a way to deploy complete variable group variables
to Azure Function app settings
using Yaml.有没有办法使用 Yaml 将完整的
variable group variables
部署到Azure Function app settings
。
Below is the yaml code and how I am deploying variable:-下面是 yaml 代码以及我如何部署变量:-
variables:
- group: MyDevVariable #This is my variable group name
#Place where I am referring my variables from variable groups
deploy:
steps:
-task: AzureFunctionApp@1
inputs:
appSetting: '-Key1 $(Key1) -Key2 $(Key2)' #Key1 and Key2 are stored in variable group.
but if I have many variables, I have to mentions every variable in appSettings
as key $(key)
.但是如果我有很多变量,我必须将
appSettings
中的每个变量都提到为key $(key)
。
So Is there a way to deploying all my variables from variable group to azure function app setting.那么有没有办法将我的所有变量从变量组部署到 azure function 应用程序设置。
Any response is greatly appreciated.非常感谢任何回应。 Thanks in advance.
提前致谢。
I don't believe that you can iterate the group's variables in the YAML directly.我不相信您可以直接迭代 YAML 中的组变量。 There's no syntax to reach into the group from what I've seen.
从我所看到的情况来看,没有任何语法可以进入该组。 What you can do is to write a script that gets the variables out of the group (if you have Azure CLI installed on the agent) and then reference it later:
您可以做的是编写一个脚本,将变量从组中取出(如果您在代理上安装了 Azure CLI),然后稍后引用它:
deploy:
steps:
- task: AzureCLI@2
inputs:
name: GetSettings
azureSubscription: Your Service Connection
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
$env:AZURE_DEVOPS_EXT_PAT = '$(System.AccessToken)'
$groupVars = (az pipelines variable-group list --group-name "My Group Name") | ConvertFrom-JSON
$settingsList = ""
$groupVars.variables.PSObject.Properties | ForEach-Object {
$settingsList += "-$($_.Name) `"$($_.Value.value)`" "
}
Write-Host "##vso[task.setvariable variable=settingsList;isOutput=true]$settingsList"
Write-Host "Using settings $settingsList"
- task: AzureFunctionApp@1
inputs:
appSetting: $(GetSettings.settingsList)
NOTE: This may encounter issues with secret variables, in which case I'd store them in Azure Key Vault and use the key vault secrets task to read them into variables.注意:这可能会遇到秘密变量的问题,在这种情况下,我会将它们存储在 Azure Key Vault 中,并使用密钥保管库秘密任务将它们读入变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.