我正在尝试以编程方式扩展Azure工作者角色,但找不到资源名称的正确语法。
// Create the autoscale client.
AutoscaleClient autoscaleClient = new AutoscaleClient(new CertificateCloudCredentials(subscriptionId, cert));
AutoscaleSettingGetResponse get =autoscaleClient.Settings.Get(AutoscaleResourceIdBuilder.BuildCloudServiceResourceId("WRK-GROUP-NE01","CIW.GROUPS",true) );
AutoscaleSetting setting = get.Setting;
它返回:ResourceNotFound:不支持资源服务名称监视。 您能指出我正确的语法吗?
答案 0 :(得分:0)
您要遵循的指南基于Azure服务管理模型(又称为经典模式),该模型已过时,仅主要用于向后兼容性支持。
您应该使用最新的Microsoft.Azure.Insights nuget软件包来获取自动缩放设置。
使用上面的nuget的示例代码如下:
using Microsoft.Azure.Management.Insights;
using Microsoft.Rest;
//... Get necessary values for the required parameters
var client = new InsightsManagementClient(new TokenCredentials(token));
client.AutoscaleSettings.Get(resourceGroupName, autoScaleSettingName);
有关获得自动缩放设置的信息,请参见下面的REST API参考。
GET
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/microsoft.insights/autoscaleSettings/{autoscale-setting-name}?api-version={api-version}
要更新自动销售设置,您可以使用以下api
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}?api-version=2015-04-01
https://docs.microsoft.com/en-us/rest/api/monitor/autoscalesettings/createorupdate
希望有帮助。