azure - 使用 Azure Devops 和 Yaml 和变量组为 Azure 函数应用部署 Appsettings
问题描述
有没有办法完全部署variable group variables
到Azure Function app settings
使用 Yaml。
下面是 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
as中的每个变量key $(key)
。
那么有没有办法将我的所有变量从变量组部署到天蓝色函数应用程序设置。
非常感谢任何回应。提前致谢。
解决方案
我不相信您可以直接在 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)
注意:这可能会遇到机密变量问题,在这种情况下,我会将它们存储在 Azure Key Vault 中并使用密钥保管库机密任务将它们读入变量。
推荐阅读
- java - 在外部使用 Tomcat 从 IntelliJ 运行 Web 应用程序时,发送到 System.err 的消息在哪里?
- python - TypeError:'str'对象不可调用 - Django
- javascript - Passport.js 使用 MySQL 和 Node.js 成功登录挂起没有错误
- c++ - 如何使用关键字打印出字母表的二维数组?
- vimeo-api - 如何获取 Vimeo API 的按需 id
- android - android上的angular 7部署,cordova是否必要?
- python - 使用 tkinter 和 ImageTk 的图像幻灯片放映
- python - 当我使用 openpyxl 编写单元格时出现了一些错误
- ajax - CORS 原始请求被阻止 - 我可以从客户端做什么?
- java - 根据激活的 Maven 配置文件更新战争名称