Reputation: 38
Based on this how-to for scaling Azure app services programmatically: Is it possible to scale Azure app services programmatically, I am trying to recreate this for Azure Cloud Services (classic), using the Azure.Management.Compute.ComputeManagementClient.
This is what I have so far. It works to a point, but I can never get my cloud services listed from the API:
Dim credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(Client_Id, clientSecret, tenant_Id, AzureEnvironment.AzureGlobalCloud)
Dim client = New Microsoft.Azure.Management.Compute.ComputeManagementClient(credentials)
client.SubscriptionId = subscription_id
Dim servicesclient = client.CloudServices
Dim cloudservices = servicesclient.ListWithHttpMessagesAsync("MyResourceGroupName").Result.Body
Everything seems to work as expected to this point. If I put in the wrong resource group name, I get an error that the resource group does not exist. But when I put in the right resource group name, the expected list of cloud services comes back empty. It's possible there is some sort of permissioning issue, although I have checked that fairly carefully. Or is the CloudServices API here different than my 'classic' cloud services? Or is there something else I'm missing?
Upvotes: 1
Views: 165
Reputation: 21883
I also recommand you use restapi to scale your roles.
I don't find offical restapi on this site. I found scale roles api by F12 when I click save
button.
If you need other restapi functions, you can also use this method to find them quickly when the official api is not found.
PATCH Method
https://management.azure.com/subscriptions/<your_subscriptions>/resourceGroups/<your_resourcegroup_name>/providers/Microsoft.ClassicCompute/domainNames/<your_cloud_service_name>/slots/production/roles/WebRole1?api-version=2016-04-01
Header
Content-Type:application/json
Body:
{"sku":{"name":"Standard_D1_v2","tier":"Standard","capacity":2}}
Auth
Bear Token
Upvotes: 1