pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
129 stars 35 forks source link

WebAppSiteExtension : Extension Install Failed #558

Open stawen opened 3 years ago

stawen commented 3 years ago

hi,

With Azure nextGen, I build a windows App Service Plan. and webapp, I want to activate an extension (here dynatrace, same problem with others). All resources are created correctly unless extension

I've got this error

(Code = "Failed" Message = "The async operation failed).

I test with an ARM template and it worked. I based my pulumi code on the ARM template.

Steps to Reproduce

Pulumi code

Just WebAppSiteExtension doesn't work

(Code = "Failed" Message = "The async operation failed).
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

import * as web_v20200901 from "@pulumi/azure-nextgen/web/v20200901";
import * as web_v20181101 from "@pulumi/azure-nextgen/web/v20181101";

// Create an Azure Resource Group
export const rg = new azure.core.ResourceGroup(`rg-demo-webapp-java`, {
    name : `rg-demo-webapp-java-dev`,
});

//--------------------------------------------------------------------------
// Create Azure Web APP (App Service Plan Windows) | Provider Azure-NextGen
//--------------------------------------------------------------------------

// App Service Plan = ServerFarm
const appServicePlanWindows = new web_v20200901.AppServicePlan("asp-webbapp-w-java", {
    name: `asp-webbapp-w-java-dev`,
    resourceGroupName: rg.name,
    location: rg.location,
    kind: "app",

    sku: {
        name: "S1",
        tier: "Standard",
        size: "S1",
        family: "S",
        capacity: 1,
    },
});

const appDemoWindows = new web_v20181101.WebApp(`demo-webapp-w-java`, {
    resourceGroupName: rg.name,
    location: appServicePlanWindows.location,
    name: `demo-webapp-w-java-dev`,
    serverFarmId: appServicePlanWindows.id,

    siteConfig: {
        appSettings: [ //Env Var
            {
                name: "VAR",
                value: "test"
            },
        ],
        // Runtime
        javaVersion: "11",
        javaContainer: "JAVA",
        javaContainerVersion: "SE",
        alwaysOn: true,
    }    
});

const extDynatrace = new web_v20181101.WebAppSiteExtension('dynatrace-siteExtension',{
    resourceGroupName: rg.name,
    name: appDemoWindows.name,
    siteExtensionId: "Dynatrace"
})

Template ARM that work

In this ARM, i create only extension on previously resource created

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "sites_demo_webapp_w_java_dev_name": {
            "defaultValue": "demo-webapp-w-java-dev",
            "type": "String"
        },
        "serverfarms_asp_webbapp_w_java_dev_externalid": {
            "defaultValue": "/subscriptions/<sub-id>/resourceGroups/rg-demo-webapp-java-dev/providers/Microsoft.Web/serverfarms/asp-webbapp-w-java-dev",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [{
        "type": "Microsoft.Web/sites/siteextensions",
        "apiVersion": "2018-11-01",
        "name": "[concat(parameters('sites_demo_webapp_w_java_dev_name'), '/Dynatrace')]",
        "location": "France Central"
    }]
}

AZURE API REST

We see this issues https://github.com/Azure/azure-rest-api-specs/issues/2819

As suggested by @hovsepm here, Azure SDK calls fail to create site extensions when they attempt to PUT a request with null content. Setting request body to an empty JSON object ({}) fixes the problem.

so we test it and voila, if you leave your body empty, it doesn't work,

image

but if you put {}, it's work !

image

if this can help you to solved it ;)

Context (Environment)

Azure France Central @pulumi/azure@3.46.0 @pulumi/azure-nextgen@0.6.0 @pulumi/pulumi@2.20.0 @types/node@10.17.51

mikhailshilkov commented 3 years ago

Thank you for such a detailed issue and investigation!

Indeed, we are not sending any body because the API spec defines no body parameters.

It seems like we behave similarly to the Azure SDK here, which is always our first comparison.

We could send an empty body for such cases. However, a quick check shows that there are several dozens of resources without a body parameter - we would need to test how they behave for empty body vs. nil body.

stawen commented 2 years ago

@mikhailshilkov hi, for information, i have tested with azure-native, i have the same issue.

gpduck commented 2 years ago

I'm having the same problem with the same site extension. Would it be possible to add a property to the auto-generated code that would allow us to either add the body or not and thus avoid possibly breaking other extensions?

gpduck commented 2 years ago

FYI I've opened up an issue on the Azure SDK project for this as well since it is also broken.

https://github.com/Azure/azure-sdk-for-js/issues/21116

AIZ-THerring commented 2 years ago

a quick check shows that there are several dozens of resources without a body parameter

I'm fairly certain that a PUT operation is always supposed to have a body:

image

jonathan-mcewan commented 7 months ago

Hey guys,

This realistically is a server / documentation issue, probably not an Azure SDK issue (which is probably why it's being ignored by MS?). I can confirm that sending {} in the PUT command successfully creates the WebAppSiteExtension.

@mikhailshilkov the complexities and risks of going against the documentation understandable. If only MS's API's had a little more resilience we wouldn't be in this situation where there's no movement from any side, and everyone suffers.