Azure - Update Resource Property with REST API

2019-05-28 14:21发布

问题:

I'm using the REST API to create resources (WebApp + MySQL) with a template. It works fine. I want now to modify the hostnames and add one but I just receive a Bad Request (400) response.

The URL I refer to is:

"https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/<myResourceGroup>/providers/Microsoft.Web/sites/<instanceName>?api-version=2015-08-01"

I'm doing a PUT, and sending the following JSON object.

{
  "properties": {
  "HostNames":"instanceName.azurewebsites.net, newHostName.com"
  }
}

It is possible that my JSON is wrong, but I tried many formats and no one works. I tried also referring to another URL:

"https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/<myResourceGroup>/providers/Microsoft.Web/sites/<instanceName>/config/web?api-version=2015-08-01"

And the response is OK (200) but then I check the resource with powershell and my HostNames property didn't change.

I also tried to set the HostNames with my template upon deployment but by default Azure does not allow you to add custom hostnames.

Anyone faced this before?