Azure自动缩放(400)错误请求
我试图通过代码隐藏来增加实例数 首先,我创建了一个.cer文件和.pfx文件,并将其上载到.pfx到cloudservice证书和.cer到settings-->管理证书 在我的代码中使用.cer文件之后。我不太清楚这个上传文件是真的吗 这是我的密码:Azure自动缩放(400)错误请求,azure,autoscaling,Azure,Autoscaling,我试图通过代码隐藏来增加实例数 首先,我创建了一个.cer文件和.pfx文件,并将其上载到.pfx到cloudservice证书和.cer到settings-->管理证书 在我的代码中使用.cer文件之后。我不太清楚这个上传文件是真的吗 这是我的密码: string subscriptionId = "c034e905-......"; string serviceName = "multitenant"; string configFileName = "Ser
string subscriptionId = "c034e905-......";
string serviceName = "multitenant";
string configFileName = "ServiceConfiguration.cscfg";
string roleName = "Multi.Web";
XNamespace xs = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
XDocument configDocument = XDocument.Parse(String.Join("", File.ReadAllLines(Path.GetFullPath(configFileName))));
XAttribute instanceCountAttribute = configDocument.Element(xs + "ServiceConfiguration")
.Elements(xs + "Role")
.Where(xRole => xRole.Attribute("name").Value == roleName).SingleOrDefault()
.Element(xs + "Instances")
.Attribute("count");
int currentInstanceCount = int.Parse(instanceCountAttribute.Value);
我正在检查我的虚拟机中的一些字段,并增加我的currentInstanceCount
double processorTotal = Convert.ToDouble(performanceCounter.CounterValue);
instanceCountAttribute.Value = (currentInstanceCount + 1).ToString();
var serviceManagment = ServiceManagementHelper.CreateServiceManagementChannel("WindowsAzureEndPoint",
new X509Certificate2("multitenant.cer"));
var changeConfigInput = new ChangeConfigurationInput();
changeConfigInput.Configuration = ServiceManagementHelper.EncodeToBase64String(configDocument.ToString());
try
{
serviceManagment.ChangeConfigurationBySlot(subscriptionId, serviceName, "Production", changeConfigInput);
}
catch (WebException e)
{
throw new Exception(new StreamReader(e.Response.GetResponseStream()).ReadToEnd());
}
ChangeConfigurationBySlot方法正在引发异常:
远程服务器返回意外响应:(400)请求错误。
我错在哪里?我不明白。是关于方法参数还是错误的上传证书
你有什么估计吗
谢谢。我解决了我的问题
这与认证无关。首先,我获取生产配置文件,更改其当前实例数并重新部署
代码如下:
var deployment=managementClient.GetDeploymentBySlot(subscriptionId,serviceName,“Production”)
string configurationXml = ServiceManagementHelper.DecodeFromBase64String(deployment.Configuration);
serviceConfiguration = XDocument.Parse(configurationXml);
XNamespace xs = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration";
instanceCountAttribute = serviceConfiguration.Element(xs + "ServiceConfiguration")
.Elements(xs + "Role")
.Where(xRole => xRole.Attribute("name").Value == roleName).SingleOrDefault()
.Element(xs + "Instances")
.Attribute("count");
currentInstanceCount = int.Parse(instanceCountAttribute.Value);