Azure Pipeline [Azure Functions for container] task appSettings multi parameter

상준 이 251 Reputation points
2022-01-12T08:45:53.537+00:00

Hello.
I have been developing and deploying .NET 5 Isolated-Process Azure Functions through visual studio 2019.
Copied the value of the Application configuration setting in local.settings.json from the Publish feature in Visual Studio 2019.

Now I want to deploy .NET 5 Isolated-Process Azure Functions via Azure Pipeline.
Below is my yaml file and dockerfile for publishing of Azure Functions.

   yaml  
   trigger:  
     branches:  
       include:  
         - main  
   variables:  
     BuildConfiguration: Release  
     ProjectName: TestAzureFunctionDocker  

   stages:  
     - stage: build  
       jobs:  
         - job: buildapp  
           displayName: Build App  
           pool:  
             vmImage: ubuntu-20.04  
           steps:  
             - task: NuGetToolInstaller@1  
               inputs:  
                 versionSpec:   
             - task: UseDotNet@2   
               displayName: Use .NET Core 3.1 SDK  
               inputs:  
                 packageType: 'sdk'  
                 version: '3.1.x'  
             - task: UseDotNet@2  
               displayName: Use .NET 5 SDK  
               inputs:  
                 packageType: 'sdk'  
                 version: '5.0.x'  
                 includePreviewVersions: true  
                 performMultiLevelLookup: true  
             - task: DotNetCoreCLI@2  
               displayName: dotnet restore  
               inputs:  
                 command: 'restore'  
                 projects: '$(System.DefaultWorkingDirectory)/$(ProjectName)/$(ProjectName).csproj'  
                 feedsToUse: 'select'  
                 vstsFeed: 'my feed guid'  
             - task: NuGetCommand@2  
               displayName: nuget restore  
               inputs:  
                 command: 'restore'  
                 restoreSolution: '$(System.DefaultWorkingDirectory)/$(ProjectName)/$(ProjectName).csproj'  
                 feedsToUse: 'config'  
                 nugetConfigPath: '$(System.DefaultWorkingDirectory)/$(ProjectName)/nuget.config'  
             - task: DotNetCoreCLI@2  
               displayName: dotnet build $(BuildConfiguration)  
               inputs:  
                 command: 'build'  
                 arguments: '--configuration $(BuildConfiguration)'  
                 projects: '$(System.DefaultWorkingDirectory)/$(ProjectName)/$(ProjectName).csproj'  
             - task: DotNetCoreCLI@2  
               displayName: dotnet publish  
               inputs:  
                 command: 'publish'  
                 arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'  
                 projects: '$(System.DefaultWorkingDirectory)/$(ProjectName)/$(ProjectName).csproj'  
                 publishWebProjects: false  
                 modifyOutputPath: false  
                 zipAfterPublish: false  
             - task: NuGetAuthenticate@0  
             - task: DockerInstaller@0  
               inputs:  
                 dockerVersion: '17.09.0-ce'  
             - task: Docker@2  
               displayName: build docker image  
               inputs:  
                 containerRegistry: 'Azure Functions Pipeline'  
                 repository: 'mytestimage'  
                 command: 'build'  
                 Dockerfile: '$(System.DefaultWorkingDirectory)/$(ProjectName)/Dockerfile'  
                 arguments: '--build-arg PAT=$(PAT)'  
             - task: Docker@2  
               displayName: docker image push to azure container registry  
               inputs:  
                 containerRegistry: 'Azure Functions Pipeline'  
                 repository: 'mytestimage'  
                 command: 'push'  
             - task: AzureFunctionAppContainer@1  
               inputs:  
                 azureSubscription: 'My MSP Service Connection'  
                 appName: 'azservicebustriggercontainertest'  
                 imageName: 'myacrname/mytestimage:$(Build.BuildId)'  
                 appSettings: |  
                   -CloudOption:ContainerName "string0"  
                   -CloudOption:AccessKeyId "string1"  
                   -CloudOption:SecretKey "string2"  
                   -CloudOption:ProjectId "string3"  
                   -CloudOption:DomainId "string4"  
                   -CloudOption:Account "string5"  



   Dockerfile  
   FROM mcr.microsoft.com/azure-functions/dotnet-isolated:3.0-dotnet-isolated5.0 AS base  
   WORKDIR /home/site/wwwroot  
   EXPOSE 80  

   FROM mcr.microsoft.com/dotnet/runtime:3.1 as runtime3_1  
   FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build  
   COPY --from=runtime3_1 /usr/share/dotnet/host /usr/share/dotnet/host  
   COPY --from=runtime3_1 /usr/share/dotnet/shared /usr/share/dotnet/shared  

   WORKDIR /src  

   RUN curl -L https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | sh  
   ARG PAT  
   ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"my azure devops private nuget feed uri\", \"password\":\"${PAT}\"}]}"  

   FROM build AS publish  
   COPY . /src/dotnet-function-app  
   RUN cd /src/dotnet-function-app && \  
       mkdir -p /home/site/wwwroot && \  
       dotnet publish /src/dotnet-function-app/TestAzureFunctionDocker.csproj --output /home/site/wwwroot  

   FROM base AS final  
   WORKDIR /home/site/wwwroot  
   ENV AzureWebJobsScriptRoot=/home/site/wwwroot \  
       AzureFunctionsJobHost__Logging__Console__IsEnabled=true  

   COPY --from=base ["/home/site/wwwroot", "/home/site/wwwroot"]  

Important information has been deleted.

All Task Steps succeeded and 'Azure Functions for container' failed.

Starting: AzureFunctionAppContainer

Task : Azure Functions for container
Description : Update a function app with a Docker container
Version : 1.195.0
Author : Microsoft Corporation

Help : https://aka.ms/azurefunctioncontainertroubleshooting

Got service connection details for Azure App Service:'azservicebustriggercontainertest'
Trying to update App Service Configuration settings. Data: {"appCommandLine":null,"linuxFxVersion":"DOCKER|myacrname/mytestimage:1069"}
Updated App Service Configuration settings.
Restarting App Service: azservicebustriggercontainertest
App Service 'azservicebustriggercontainertest' restarted successfully.
Trying to update App Service Application settings. Data: {"CloudOptionContainerName":"\"string0\"\n->CloudOptionAccessKeyId","":"AUTH_8556e13c15264137a6a9e78811845b46","WEBSITES_ENABLE_APP_SERVICE_STORAGE":"false"}
[error]Error: Failed to update App service 'azservicebustriggercontainertest' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)
Successfully added release annotation to the Application Insight : azservicebustriggercontainertest
Successfully updated deployment History at https://azservicebustriggercontainertest.scm.azurewebsites.net/api/deployments/10691641974029296
App Service Application URL: http://azservicebustriggercontainertest.azurewebsites.net
Finishing: AzureFunctionAppContainer

Looking at the log, it seems that the setting value is not entered properly.

Also, if you set App Settings with Generic Host Configuration in C#, you set it this way, but I wonder if you set and update in the same way in azure pipeline.

In conclusion, how can I write yaml in Azure Pipeline to configure multiple settings as if they were used in Generic Host in C#?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,193 questions
0 comments No comments
{count} votes

Accepted answer
  1. Samara Soucy - MSFT 5,131 Reputation points
    2022-01-13T00:20:18.35+00:00

    We want to make sure your question is read by the right people (who will be able to give you the best answers), and Azure DevOps is not currently supported through this forum.. Please post your question in the following forum, where the Microsoft DevOps team and community are actively answering questions:
    https://stackoverflow.com/questions/tagged/azure-devops


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.