0

I am trying to create a VM using the azure Rest API. I am trying to call the REST Api through Postman.

PUT Request:- https://management.dev.azure.com/subscriptions/subscriptionID/resourcegroups/ResourceGroupName/providers/Microsoft.Resources/deployementName/DetDeployment?api-version=2019-05-01

I am using the above REST API with my subscription ID and resouceGroupName.

In the Authorization section, I am providing the Type as Basic Authentication and passing my credentials in the username and password section. Along with this, I am also passing values in the Body section.

{
 "properties": {
   "templateLink": {
     "uri": "https://mystoragename.blob.core.windows.net/templates/VMTemplate.json",
     "contentVersion": "1.0.0.0"
   },
   "parametersLink": {
     "uri": "https://mystoragename.blob.core.windows.net/templates/VMParam.json",
     "contentVersion": "1.0.0.0"
   },
   "mode": "Incremental",
   "debugSetting": {
     "detailLevel": "requestContent, responseContent"
   }
 }
}

Whenever I am sending this request so it is giving me an error like 400 Bad Request and message in the body section is :

Our services aren't available right now

We're working to restore all services as soon as possible. Please check back soon.

0ddImXQAAAABmya8eHqWDRp1JX69tDGdATUFBMDFFREdFMDIyMABFZGdl

Please tell me what wrong I am Doing here. From last 1 day, I am trying this.

Abhinav Sharma
  • 299
  • 1
  • 8
  • 20

1 Answers1

2

Looks like your resource is wrong, it should be https://management.azure.com not https://management.dev.azure.com.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}?api-version=2019-05-01

Reference - Deploy resources with Resource Manager templates and Resource Manager REST API

Besides, I notice you use the Basic Authentication, not sure if it works for azure rest API(I think may not), even the way will work, but if your account is MFA-enabled, then you will not be able to use that.

So for the Authentication, i recommend you to see this link to get an access token to call the rest api. Or you could try the easiest way -> click Try it in this doc -> login in your account -> then you will be able to test the rest api like that in postman. Also, you can copy the Authorization token and test it in the postman.

enter image description here

Joy Wang
  • 39,905
  • 3
  • 30
  • 54
  • Thanks, Joy. It works. But when I am sending the request from postman it is returning me the complete arm template josn in the response and status code is 200. When I look into my Azure account it not show my VM. – Abhinav Sharma Jul 11 '19 at 10:39
  • @AbhinavSharma Make sure the resource group is right, or may be some delay? – Joy Wang Jul 11 '19 at 10:43
  • Same happening with Try it application .status code is 200 and it returns the ARM template json. Also, the resource group is right. Even after 10 min, nothing is happening. Checked the Virtual machine section in Azure portal nothing is there. – Abhinav Sharma Jul 11 '19 at 10:51
  • @AbhinavSharma It seems to be wired, could you make sure the content of template is right? If you deploy the template directly in the azure portal -> deploy custom template, will it work? – Joy Wang Jul 11 '19 at 10:55
  • 1
    Thanks, @JoyWang.Problem is with the network interface. Because I have used this template earlier so it is not able to delete a network interface. Error:-Network Interface nic0 is used by existing resource. But still strange instead of throwing error API returning 200.And this is happening from starting of my requests. – Abhinav Sharma Jul 11 '19 at 11:02
  • 1
    If 201 return, It means now this request will create the VM in Azure portal. From Activity logs, we can check what is happening around. Thanks, JoyWang. – Abhinav Sharma Jul 11 '19 at 11:34