Equivalent Azure ARM APIs for ComputeManagementClient operations like create, get, swap

395 Views Asked by At

I have to replace the service management API's with Azure ARM and I am finding very difficult to find a proper documentation for the following equivalent Azure ARM API's

1) ComputeManagementClient.Deployments.Create - I found the API to GET deployment by slot with the help of azure resource explorer.

https://management.azure.com/subscriptions/{mySubID}/resourceGroups/{myResourcegroup}/providers/Microsoft.ClassicCompute/domainNames/{myCloudService}/slots/Production?api-version=2016-04-01

What is PUT/POST request body for the same ?

2) ComputeManagementClient.Deployments.swap - What is the API to Swap deployment with Production slot ?

3) ComputeManagementClient.HostedServices.Create

 https://management.azure.com/subscriptions/{mySubID}/resourceGroups/{myResourcegroup}/providers/Microsoft.ClassicCompute/domainNames/{myCloudService}/slots/Production?api-version=2016-04-01

Will the above API create cloud service ? If so what are the parameters should be in the Request body ?

2

There are 2 best solutions below

0
On

For Deployments.Create please refer to 4c74356b41's answer. I test the create cloudservice and swap slot on my side, it works correctly.

ComputeManagementClient.Deployments.swap - What is the API to Swap deployment with Production slot ?

please have a try to use the following REST API to swap the deployment with Production slot.

post https://management.azure.com/subscriptions/{subscriptionid}/resourceGroups/{resourcegroupname}/providers/Microsoft.ClassicCompute/domainNames/{cloudservicename}/swap?api-version=2015-06-01

enter image description here

Will the above API create cloud service ? If so what are the parameters should be in the Request body ?

Yes, we could use the Rest API to create cloudservice.

put https://management.azure.com/subscriptions/{subscriptionid}/resourceGroups/{resourcegroupname}/providers/Microsoft.ClassicCompute/domainNames/{cloudservicename}?api-version=2016-04-01

Body:

  {
   "properties": {},
   "location": "eastus" //location
  }

enter image description here

Note: please make sure that your subcription supports to create the cloudservice in that location. If it is not supported, we will get the following error.

The location constraint is not valid

0
On

To create deployment slot you can adapt this arm template piece (properties would be the body, path would be combination of name + type), refer to this for some additional examples:

    {
        "apiVersion": "2015-06-01",
        "name": "slotName",
        "type": "Microsoft.ClassicCompute/domainNames/slots",
        "dependsOn": [
            "cloudServiceName"
        ],
        "properties": {
            "deploymentLabel": "[parameters('deploymentLabel')]",
            "packageLink": {
                "Uri": "[parameters('packageLink')]"
            },
            "configurationLink": {
                "Uri": "[parameters('configurationLink')]"
            },
            "deploymentOptions": "[parameters('deploymentOptions')]"
        }
    }

Also, your best source of such information is fiddler ;) ( at least that how I got to know it )