【问题标题】:How to programmatically scale Azure Cloud Service (classic) roles如何以编程方式扩展 Azure 云服务(经典)角色
【发布时间】:2021-07-05 09:15:01
【问题描述】:

基于此以编程方式扩展 Azure 应用服务的方法: Is it possible to scale Azure app services programmatically, 我正在尝试使用 Azure.Management.Compute.ComputeManagementClient 为 Azure 云服务(经典)重新创建它。

这是我目前所拥有的。它在一定程度上有效,但我永远无法从 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

到目前为止,一切似乎都按预期工作。如果我输入了 错误 资源组名称,则会收到资源组不存在的错误消息。但是,当我输入 right 资源组名称时,预期的云服务列表返回为空。可能存在某种许可问题,尽管我已经相当仔细地检查过了。还是这里的 CloudServices API 与我的“经典”云服务不同?还是我还缺少其他东西?

【问题讨论】:

  • 我觉得sdk的使用需要严格按照文档使用。如果对文档不是很熟悉,不建议使用sdk。
  • 如果我的回复有帮助,请采纳为答案(点击回复旁边的标记选项将其从灰色切换为填写。),请参阅meta.stackexchange.com/questions/5234/…

标签: azure azure-cloud-services azure-management-api


【解决方案1】:

我还建议您使用 restapi 来扩展您的角色。

我没有找到官方的 restapi on this site。当我点击save 按钮时,我通过 F12 找到了 scale roles api。

提示

如果你需要其他restapi功能,也可以在官方没有找到api的时候用这个方法快速找到。

PATCH 方法

https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.ClassicCompute/domainNames//slots/production/roles/WebRole1 ?api-version=2016-04-01

标题

内容类型:应用程序/json

正文:

{"sku":{"name":"Standard_D1_v2","tier":"Standard","capacity":2}}

授权

熊令牌

【讨论】:

  • 谢谢!我怀疑有某种后门方法可以做到这一点,但希望能避免它。但是,如果这是唯一的方法,我会尝试一下,看看我是否可以让它工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-30
  • 2013-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-08
相关资源
最近更新 更多