如何从 ADO 管道中的任务 AzureFunctionApp 配置 ENV 值?

发布于 2025-01-11 17:53:38 字数 873 浏览 0 评论 0原文

如何从 ADO 管道中的任务 AzureFunctionApp 配置 ENV 值?基本上,当我有一个与 Terraform 分开创建的 FunctionApp 时,在上传 .jar 文件的任务中,如何在推送中包含一些环境变量?

这可能吗?

我尝试了这个,但它不起作用,并且出现编译错误。

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      configurationStrings:
        - TEST: "what"

我也尝试过这个,它可以编译并运行,但它对我来说也不起作用。部署后,环境变量不会显示在应用程序设置中。

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      appSettings: "-TEST what"

How can I configure ENV values from task AzureFunctionApp in ADO pipeline? Basically, when I have a FunctionApp that was created separately from Terraform, on this task that uploads the .jar file, how can I include some environment variables with the push?

Is this possible?

I tried this, but it doesn't work, and gets a compile error.

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      configurationStrings:
        - TEST: "what"

I also tried this, which compiles and runs, and it didn't work for me either. The env variable doesn't show up in the app settings after deploy.

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      appSettings: "-TEST what"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笨笨の傻瓜 2025-01-18 17:53:38

根据 Azure Function App 任务文档,您需要的 yaml 键是 appSettings

尝试这种方式:

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      appSettings: '-MY_ENV_VARIABLE test'

应用程序设置应遵循语法 -key 值。包含空格的值应该用双引号引起来。

According to the Azure Function App Task Documentation, the yaml key that you need is appSettings

Try this way:

  - task: AzureFunctionApp@1
    inputs:
      azureSubscription: ${{ parameters.serviceConnection }}
      appType: 'functionApp'
      appName: 'my-api-$(environment)'
      package: '$(Pipeline.Workspace)/my-api/my-api-1.0.0'
      runtimeStack: 'JAVA|11'
      appSettings: '-MY_ENV_VARIABLE test'

Application settings should follow the syntax -key value. Values containing spaces should be enclosed in double quotes.

诺曦 2025-01-18 17:53:38

我为此苦苦挣扎了一段时间,所以添加了另一个我最终得到的例子。 YAML 非常脆弱,而且现有的示例文档也不是很好。注意点是 - 不要使用任何逗号来分隔值,如果值中有空格,请将其包含在 " 中,否则只需添加值而不将其括起来。

              appSettings: 
                -TimerCron "0 0 * * * *"
                -QueueName etl
                -PurchaseOrderEligibleDays 365

I wrestled with this for a time so adding another example of what I ended up with. YAML is so brittle and the example docs out there are not much good either. Point of note are - don't use any commas to separate the values, where there are spaces in a value, wrap it in " , otherwise just add the value without surrounding it.

              appSettings: 
                -TimerCron "0 0 * * * *"
                -QueueName etl
                -PurchaseOrderEligibleDays 365
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文