1
votes

I am attempting to consume the Azure REST API to Create a new Web App as documented here.

I am using an Authorization = Bearer xxxx token created with the Scope and Resource of https://management.azure.com/.

The Registered App has the Microsoft Graph Api permission Sites.Manage.All and Application.ReadWrite.All.

I am doing a PUT to https://management.azure.com/subscriptions/{subID}/resourceGroups/{resGrp}/providers/Microsoft.Web/sites/{newName}?api-version=2016-08-01

I am specifying a content type of application/json with the following body:

{
    "location":"Central US",
    "properties":
    {
        "cloningInfo":
        {
            "sourceWebAppId":"subscriptions/{subID}/resourceGroups/{resGrp}/providers/Microsoft.Web/sites/{cloneFromName}",
            "overwrite":true,
            "ignoreQuotas":true,
            "correlationId":"some random text??"
        }
    }
}

I have also tried this similar body

{
    "location":"Central US",
    "properties.cloningInfo":
    {
        "sourceWebAppId":"subscriptions/{subID}/resourceGroups/{resGrp}/providers/Microsoft.Web/sites/{cloneFromName}",
        "overwrite":true,
        "ignoreQuotas":true,
        "correlationId":"some random text??"
    }
}

I am able to successfully call List Sites specified at this documentation.

I assume I either have the wrong Api Permissions, or I am missing some required information in the body.

1
Did my answer solve your issue?Tony Ju
Well, you answered at 10pm my time and I was sleeping. I am actually looking at it right now though. I'll certainly follow general StackOverflow procedure and update your answer ASAP.Suamere
Oh, sorry. I didn't realize this. Just take your time and let me know if you need further assistance.Tony Ju

1 Answers

1
votes

You missed ServerFarmId in the body, the body should be

{
    "location":"Central US",
    "properties":
    {
        "cloningInfo":
        {
          "sourceWebAppId":"{Resource ID of the webpp you want to clone}",
            "overwrite":true,
            "ignoreQuotas":true,
            "correlationId":"correlationId1"
        },
      "ServerFarmId":"{Resource ID of the associated App Service plan}"
    }
}

Besides, you need to confirm if your service plan supports clone app feature. Clone app is a feature that is only available to apps hosted on Standard App Service Plans. When you click Clone App on Azure portal, you will find the tip. enter image description here

You can also find more details in the response. enter image description here