azure-pipelines-tasks: App Service Deploy: Extra spaces in settings causes BadRequest

Environment

VSTS Hosted Linux Preview
adamtuliper.visualstudio.com
new.dot.net-custom-branch / Build 0.1.92+g44e6a2bc21
project: new.dot.net

Note: I’ve worked with @vincentdass on this issue via skype.

Issue Description

Task Name: Azure App Service Deploy When you edit the “Application and Configuration settings/App Settings” section, if there’s an extra space between key/values the parsing routine seems to think they are new key/values and it fails on the post request.

Example -Key1 true -Key2 "12345" Note the whitespace between true and -Key2. This will cause BadRequest - Parameter name cannot be empty. (CODE: 400)

Error logs

From this configuration setting: -UseAci true -AzureAdClientId "private"

We get the following post request. Note the empty double quotes because of the extra whitespace above.

2018-07-20T15:19:23.3087924Z Updating App Service Application settings. Data: {"UseAci":"true","":"","AzureAdClientId":"private"} 2018-07-20T15:19:23.3090434Z ##[debug][POST]https://management.azure.com/subscriptions/402fe320-hidden/resourceGroups/newdotnet/providers/Microsoft.Web/sites/hidden/config/appsettings/list?api-version=2016-08-01 2018-07-20T15:19:23.5960955Z ##[debug][PUT]https://management.azure.com/subscriptions/402fe320-hidden/resourceGroups/newdotnet/providers/Microsoft.Web/sites/hidden/config/appsettings?api-version=2016-08-01 2018-07-20T15:19:24.2656180Z ##[debug]task result: Failed 2018-07-20T15:19:24.2715267Z ##[error]Error: Failed to update App service 'hidden' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (14 by maintainers)

Most upvoted comments

I had the same issue, but it was due to spaces in my variable value.

Ex: -Key1 value1 -Key2 $(VariableKey)

The value of Variable Key in the pipeline variable contains spaces. To fix it I have added quotes : -Key1 value1 -Key2 "$(VariableKey)"

Maybe it will help you @HemanthsGithub; @lavanya56

I seem to be having the same problem with the following:

  - task: AzureRmWebAppDeployment@4
    displayName: Deploy Web App
    inputs:
      ConnectionType: 'AzureRM'
      azureSubscription: '${{ parameters.azureSubscription }}'
      appType: 'webApp'
      WebAppName: '$(appServiceName)'
      packageForLinux: '$(Pipeline.Workspace)/MyAppName/publish.zip'
      AppSettings: |
        -CosmosDb:Account "$(CosmosDbAccount)"
        -CosmosDb:Key "$(CosmosDbKey)"

producing the following error despite the values being quote wrapped, and there’s no spaces or quotes in the values being replaced.

Trying to update App Service Application settings. Data: {"CosmosDb__Account":"***\n-CosmosDb__Key","":"***"}
##[error]Error: Failed to update App service '[[redacted]]' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)

I’m reverting to using the AzureAppServiceSettings@1 as despite its noisy syntax it actually works…

Hi, I faced the similar problem, this is a spacing issue, if you look at the created JSON Data: {“CosmosDb__Account”:“\n-CosmosDb__Key", “”:"”} In order to make it work, leave a blank space after this line -CosmosDb:Account “$(CosmosDbAccount)” eg: AppSettings: | -CosmosDb:Account $(CosmosDbAccount) [<- leave a blank space here] -CosmosDb:Key $(CosmosDbKey)

Hello wokket,

Please find the screen shot with space.

image

Thanks.

Hi wokket,

We need to update the document for providing the space after key value pair.

Thanks.

I seem to be having the same problem with the following:

  - task: AzureRmWebAppDeployment@4
    displayName: Deploy Web App
    inputs:
      ConnectionType: 'AzureRM'
      azureSubscription: '${{ parameters.azureSubscription }}'
      appType: 'webApp'
      WebAppName: '$(appServiceName)'
      packageForLinux: '$(Pipeline.Workspace)/MyAppName/publish.zip'
      AppSettings: |
        -CosmosDb:Account "$(CosmosDbAccount)"
        -CosmosDb:Key "$(CosmosDbKey)"

producing the following error despite the values being quote wrapped, and there’s no spaces or quotes in the values being replaced.

Trying to update App Service Application settings. Data: {"CosmosDb__Account":"***\n-CosmosDb__Key","":"***"}
##[error]Error: Failed to update App service '[[redacted]]' application settings. Error: BadRequest - Parameter name cannot be empty. (CODE: 400)

I’m reverting to using the AzureAppServiceSettings@1 as despite its noisy syntax it actually works…

Vincent, We are using version 4.* for azure app service deploy