gpt4 book ai didi

azure - 使用 Azure Devops 和 Yaml 以及变量组部署 Azure 函数应用程序的 Appsettings

转载 作者:行者123 更新时间:2023-12-03 02:27:19 24 4
gpt4 key购买 nike

有没有办法使用 Yaml 将完整的变量组变量部署到 Azure Function 应用设置

下面是 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.

但如果我有很多变量,我必须将 appSettings 中的每个变量作为 key $(key) 提及。

有没有办法将我的所有变量从变量组部署到 azure 函数应用程序设置。

非常感谢您的任何回复。提前致谢。

最佳答案

我不相信您可以直接在 YAML 中迭代组的变量。据我所知,没有任何语法可以进入该组。您可以做的是编写一个脚本,从组中获取变量(如果您在代理上安装了 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)

注意:这可能会遇到 secret 变量的问题,在这种情况下,我会将它们存储在 Azure Key Vault 中,并使用 Key Vault secret 任务将它们读入变量。

关于azure - 使用 Azure Devops 和 Yaml 以及变量组部署 Azure 函数应用程序的 Appsettings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66455523/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com