Anders Höglund
Anders Höglund

Reputation: 13

Error creating a new Cloud Service using the Compute Management Client

I am using the Windows Azure Management Libraries to deploying new cloud services. I am trying to make a copy of an existing cloud service, but with a new name. When I try to Create a new deployment I get the following error:

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>

I have an existing clous service with name "myfirstcloudservice" and want to create a new cloud service with the name "myfirstcloudservice2" as a copy from "myfirstcloudservice".

The following pseudo-code us used:

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);
}

Upvotes: 0

Views: 3274

Answers (1)

MikeWo
MikeWo

Reputation: 10975

The issue here is you are attempting to push a deployment to a cloud service that doesn't exist. You need to make sure your code creates the myfirstcouldservice2 cloud service first, before trying your deployment.

Use the client.HostedServices.Create or CreateAsync method to first create the cloud service. You can see more info on a post by Brady Gaster.

Upvotes: 1

Related Questions