使用Compute Management Client创建新的Cloud Service时出错

时间:2013-11-12 12:26:25

标签: c# azure azure-cloud-services

我正在使用Windows Azure管理库来部署新的云服务。我正在尝试复制现有的云服务,但使用新名称。当我尝试创建新部署时,出现以下错误:

DeployNew error: Microsoft.WindowsAzure.CloudException: ResourceNotFound: The hosted service does not exist.
   at Microsoft.WindowsAzure.Management.Compute.DeploymentOperationsExtensions.Create(IDeploymentOperations operations, String serviceName, DeploymentSlot deploymentSlot, DeploymentCreateParameters parameters)
   at XXYYZZ.DeployNew() in c:\xxyyzz\Scale.cs:line 147

REQUEST BODY:
<CreateDeployment xmlns="http://schemas.microsoft.com/windowsazure">
  <Name>simulatorprocesstrainer</Name>
  <PackageUrl>https://xxyyzz.blob.core.windows.net/deployments/XXYYZZ.cspkg</PackageUrl>
  <Label>...</Label>
  <Configuration>...</Configuration>
  <StartDeployment>true</StartDeployment>
  <ExtendedProperties />
</CreateDeployment>

RESPONSE:
HTTP/1.1  NotFound (404):  Not Found
x-ms-servedbyregion: ussouth
x-ms-request-id: 8854275254702aef8c2a84a27d23f12d
Cache-Control: no-cache
Date: Tue, 12 Nov 2013 12:11:26 GMT
Server: 1.0.6198.19
Server: (rd_rdfe_stable.131030-2145)
Server: Microsoft-HTTPAPI/2.0
client-tracking-id: 1
Content-Length: 199
Content-Type: application/xml; charset=utf-8

RESPONSE BODY:
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">    <Code>ResourceNotFound</Code><Message>The hosted service does not exist.</Message></Error>

我有一个名为“myfirstcloudservice”的clous服务,并希望创建一个名为“myfirstcloudservice2”的新云服务作为“myfirstcloudservice”的副本。

我们使用了以下伪代码:

using (ComputeManagementClient client = CloudContext.Clients.CreateComputeManagementClient(CertificateAuthenticationHelper.GetCredentials()))
{
    var parameters = new DeploymentCreateParameters()
    {
        Label = "mypackagename",
        Name = "myfirstcloudservice2",
        PackageUri = package.Uri, // cspkg-file from myfirstcloudservice
        Configuration = configContent, // content from cscfg-file from myfirstcloudservice
        StartDeployment = true
    };

    client.Deployments.Create("myfirstcloudservice2", deploymentSlot, parameters);
}

1 个答案:

答案 0 :(得分:1)

此处的问题是您尝试将部署推送到不存在的云服务。在尝试部署之前,您需要首先确保您的代码首先创建myfirstcouldservice2云服务。

使用client.HostedServices.Create或CreateAsync方法首先创建云服务。您可以在post by Brady Gaster上看到更多信息。