18

I am trying to create a simple WebApp using the Azure SDK for JS in a Node.js environment, but I keep getting the response:

{
  "Code":"BadRequest",
  "Message":"The parameter LinuxFxVersion has an invalid value.",
  "Target":null,
  "Details":[
    {"Message":"The parameter LinuxFxVersion has an invalid value."},
    {"Code":"BadRequest"},
    {"ErrorEntity": {
        "ExtendedCode":"01007",
        "MessageTemplate":"The parameter {0} has an invalid value.",
        "Parameters":["LinuxFxVersion"],
        "Code":"BadRequest",
        "Message":"The parameter LinuxFxVersion has an invalid value."}
    }],
  "Innererror":null
}

I've tried a variety of different sets of properties and environments with no success. I always get this error. Here's a snippet of the TypeScript code I am using:

    const wsmClient: WebSiteManagementClient...
    const webAppName: string...
    const servicePlanId: string...
    const rgName: string...
    const envelope: Site = {
      name: webAppName,
      location: 'westus2',
      kind: 'app,linux',
      serverFarmId: servicePlanId,
      siteConfig: {
        linuxFxVersion: 'JAVA|11-java11'
      }
    };
    const appResp = await wsmClient.webApps.createOrUpdate(
      rgName,
      webAppName,
      envelope
    );

What am I doing wrong?

4 Answers 4

40

Reason:

Your app service plan is not Linux, actually it's Windows. Windows host doesn't have parameter LinuxFxVersion.

If we create a site without explicitly configuring the host as Linux, it will be a Windows host/serverFarm/app service plan by default. Using {"kind":"linux"} is not enough.

Solution:

Explicitly define the app service plan in Linux, and make sure {"reserved": true} to set it as a Linux host (See documentation)

{
    "type": "Microsoft.Web/serverfarms",
    "apiVersion": "2019-08-01",
    "name": "[parameters('hostingPlanName')]",
    "location": "[parameters('location')]",
    "kind": "app,linux",
    "properties": {
        "reserved": true
    },
    "sku": {
        "Tier": "[parameters('hostingPlanSkuTier')]",
        "Name": "[parameters('hostingPlanSkuName')]"
    }
}
1

I test your json data, it's caused your properties. Your json data has no "properties" property. If you want to create web with the json property check this web app Rest API request body:Web Apps - Create Or Update.

The correct format should be like the below sample:

  {
    "location": "CentralUS",
    "kind":"app,linux",
    "properties":{
          "serverFarmId":"your Resource ID",
        "siteConfig":{
            "linuxFxVersion":"JAVA|11-java11"
        }
    }

 }
1
  • Thanks George. You are right about needing properties, but the Azure SDK for JS has these model mappers that map JS objects (like envelope in my snippet above) to the actual request body, so the serverFarmId in my code will actually be mapped to properties.serverFarmId in the REST API request body. I've found a workaround using a template deployment, but I am still curious about the problem I'm having with the SDK for JS.
    – jgellin
    Nov 1, 2019 at 16:48
1

I had the similar issue while deploying the webapp using Terraform.

resource "azurerm_linux_web_app" "app_service" {
  name                = "app-name"
  location            = azurerm_resource_group.resourcegroup.location
  resource_group_name = azurerm_resource_group.resourcegroup.name
  service_plan_id     = azurerm_service_plan.plan.id
     
  site_config {
    application_stack {
      docker_image     = "<image-registry>"
      docker_image_tag = var.GIT_VERSION
    }
  }
}

In my case, docker_image_tag version was not populated correctly. After providing the correct value, Terraform deployed successfully.

0

@imwenyz answer helped me.

I am running as Azure DevOps pipeline, which has AzureWebApp@1 task. And the app service on Azure that I configured is windows based.

I am getting the error at this task as follows.

##[error]Error: Failed to patch App Service 'BasicReactApp' configuration. Error: BadRequest - The parameter LinuxFxVersion has an invalid value. (CODE: 400)

So I had to modify the task as follows.

      - task: AzureWebApp@1
        displayName: 'Azure Web App Deploy: '
        inputs:
          azureSubscription: $(azureSubscription)
          #appType: webAppLinux # this is the cause for the error in my case.
          appType: webApp
          appName: $(webAppName)
          runtimeStack: 'NODE|14.x'
          package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
          startUpCommand: 'npm run start'

Basically, as you can see, changed the appType from webAppLinux to webApp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.