코드에 의한 인스턴스 카운트를 증가 시키려고합니다.Azure Autoscaling (400) 잘못된 요청
우선 .cer 파일과 .pfx 파일을 하나 만들고 .pfx로 클라우드 서비스 인증서에, .cer. 설정 -> 관리 인증서로 업로드합니다.
내 코드에서 .cer 파일을 사용한 후. 나는이 uplod 파일이 사실인지 잘 모른다.
여기 내 코드입니다 :
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);
와 내 VM에서 일부 필드를 확인하고 내가 내 currentInstanceCount을 incease.
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) 잘못된 요청 :
원격 서버가 예기치 않은 응답을 반환.
어디에서 잘못 되었나요? 나는 이해할 수 없었다. 메서드 매개 변수 또는 잘못된 업로드 인증서입니까?
예상치가 있습니까?
감사합니다.