Option 1 Attach an empty data disk to the role by specifying the
disk label and location of the disk image.
Can you try by removing the <DiskName> element from your request body and see if that works?
Also not sure how you would do this in Java but when you get a 400 exception, if you parse the response body, you should see detailed error message. For example, in .Net we do something like this:
catch (WebException webEx)
using (var resp = (HttpWebResponse)webEx.Response)
using (var respStreamReader = new StreamReader(resp.GetResponseStream()))
var errorMessage = respStreamReader.ReadToEnd();//errorMessage will be XML containing detailed error message.
So I just tried creating an empty data disk using the API, and I get 400 error under two situations:
If I include <DiskName> element in my request body. Once I removed this element, I was able to successfully create a data disk. So your request body should not contain this element.
<DataVirtualHardDisk xmlns=""http://schemas.microsoft.com/windowsazure"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
wow - love your blog! ... so I tried to remove both the DiskName and then the MediaLink tags and still got bad request. As far as I can tell, it's the con.getOutputStream method that would throw an exception - that only throws an IOException and that didn't happen when I put in a try/catch.
Just remove the DiskName and leave the MediaLink tag.
sorry - probably didn't make it clear: I tried removing DiskName first and leaving MediaLink that didn't work. Then I tried removing both - still didn't work.
That should have worked. Does the storage account specified in the media link element belong to the same subscription?
Guarav - would you be able to share your URL and request xml? also - did you set your x-ms-version to '2012-03-01' or to a later date?