简体   繁体   English

部署 Azure function 应用程序的应用程序设置使用 Azure Devops 和 Z65F603ZDevops 和 Z65F6036BFC967981CE2333036BFC96798CE23

[英]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.

相关问题 Azure DevOps CI/CD 部署 Web 或 Function 应用程序更改 Z9463F832F8B5261Z 管道中的应用程序设置中的值FBD8403F8185CABED1FCE - Azure DevOps CI/CD Deploy Web or Function App changing the values in appsettings in YAML Pipelines Azure Pipelines YAML - 将变量组用于“部署 Web 应用程序”azureSubscription 输入时出错 - Azure Pipelines YAML - error when using variable group for "Deploy Web App" azureSubscription input Azure Devops Pipeline 中的变量组 yaml 变量表达式 - Variable group yaml variable expression in Azure Devops Pipeline 如何将 function 应用程序设置部署到 azure function 应用程序使用 ZCF04A02E37B774FC3597 devop8 - How to deploy function app settings to azure function app using azure devops app service deployment task 使用 Azure Devops yaml 管道部署到本地服务器 - Using Azure Devops yaml pipelines to deploy to on-prem servers AspNetCore AppSettings Azure DevOps - AspNetCore AppSettings Azure DevOps 如何使用Azure DevOps在Nure应用服务上部署Nupkg文件 - How to deploy nupkg files on azure app service using azure devOps Azure DevOps - 在部署组中的目标计算机上设置环境变量 - Azure DevOps - Setting An Environment Variable on the Target Machine in a Deploy Group Azure DevOps 变量组未在 Azure 函数配置中应用 - Azure DevOps Variable Group not applying in Azure Function Configuration 使用 Azure DevOps(Python 3.7)部署 Azure function - 错误 500 - Deploy a Azure function using Azure DevOps (Python 3.7) - Error 500
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM