问题
This started out as a SubscriptionNotFound error.
Then I ended up with a MissingRegistrationForLocation error.
And now I'm here.
Same code:
var dnsClient = new DnsManagementClient(new Microsoft.Azure.TokenCloudCredentials(result.AccessToken));
var zone = dnsClient.Zones.CreateOrUpdate("someresourcegroup", "mydomain.com", new Microsoft.Azure.Management.Dns.Models.ZoneCreateOrUpdateParameters {
IfNoneMatch = "*",
Zone = new Microsoft.Azure.Management.Dns.Models.Zone {
Name = "mydomain.com",
Location = "global"
}
});
And this bug:
BadRequest: The body of the request is empty or does not have the expected content.
The other 2 errors makes sense, but this one seems a bit like a dead-end.
What Am I doing wrong this time around?
回答1:
Please change your code and include Properties:
var zone = dnsClient.Zones.CreateOrUpdate("someresourcegroup", "mydomain.com", new Microsoft.Azure.Management.Dns.Models.ZoneCreateOrUpdateParameters
{
IfNoneMatch = "*",
Zone = new Microsoft.Azure.Management.Dns.Models.Zone
{
Name = "mydomain.com",
Location = "global",
Properties = new ZoneProperties()//Add this line!
}
});
That should take care of the problem.
来源:https://stackoverflow.com/questions/35081852/azure-badrequest-the-body-of-the-request-is-empty-or-does-not-have-the-expecte