0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

azure-pipelines.ymlでアプリ設定を追加・更新する

Last updated at Posted at 2024-07-11

Azure Functionsのアプリ設定する例

AzureFunctionApp@2タスクのappSettingsは、文字列なので使い難い。。。

改行とか入ってしまうとダメ

appSettings - App settings
string.

Enter the application settings using the syntax -key value
(for example: -Port 5000 -RequestTimeout 5000 -WEBSITE_TIME_ZONE).
Enclose values that contain spaces in double quotes (for example: "Eastern Standard Time").

AzureAppServiceSettings@1タスクだと、JSONでしっかり書ける

以下は、azure-pipelines.ymlの抜粋

azure-pipelines.yml
variables:
  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: "<DevOpsのService connections>"

  # リソースグループ名  
  resourceGroupName: "sample-group"

  # Function名
  functionAppName: "sample-func"

  # Agent VM image name
  vmImageName: "ubuntu-latest"

  # Working Directory
  workingDirectory: "$(System.DefaultWorkingDirectory)/"

  # 今回はAppConfigurationのエンドポイント
  appConfigurationEndpoint: "https://sample-app-config.azconfig.io"

  - stage: Deploy
    displayName: Deploy stage
    dependsOn: Build
    condition: succeeded()

    jobs:
      - deployment: Deploy
        displayName: Deploy
        environment: "development"
        pool:
          vmImage: $(vmImageName)

        strategy:
          runOnce:
            deploy:
              steps:
                - task: AzureFunctionApp@2
                  displayName: "Azure functions app deploy"
                  inputs:
                    azureSubscription: "$(azureSubscription)"
                    appType: functionAppLinux
                    resourceGroupName: $(resourceGroupName)
                    appName: $(functionAppName)
                    package: "$(Pipeline.Workspace)/drop/$(Build.BuildId).zip"
                    appSettings: |
                      [
                        {
                          "name": "HOGE",
                          "value": "VAR​"
                        },
                        {
                          "name": "POSTGRES_SERVER",
                          "value": "@Microsoft.AppConfiguration(Endpoint=$(appConfigurationEndpoint); Key=POSTGRES_SERVER)​"
                        }
                      ]

おわり

何故かAzureFunctionApp@2のappSettingsだとエラーになる

Updating App Service Application settings. Data: {"":"[   {\n    \"name\": \"POSTGRES_SERVER\",\n    \"value\": \"@Microsoft.AppConfiguration(Endpoint=https://sample-app-config.azconfig.io; Key=POSTGRES_SERVER)​\"\n  }\n]"}
##[error]Error: Failed to update App service 'sample-func' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?