Geeks With Blogs

News Please visit me at my new blog!!

profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.



Programming and Learning from SD

We are automatically deploying a package to Azure, then running tests against that instance. See Brady Gaster’s article for more details. I needed a way to make sure the deployment was complete, and if not wait for it. After digging through the objects with Intellisense, we found this solution:

public bool IsCloudServiceRunning()
{
    var details = _computeManagementClient.HostedServices.GetDetailed(_parameters.CloudServiceName);
    var deployment = details.Deployments.First(d => d.Name == _parameters.CloudServiceName + "Prod");
    Debug.WriteLine("Checking is cloud service running. Current Status: " + deployment.Status);
    return deployment.Status == DeploymentStatus.Running;
}
 
The constructor:
public AzureDeploymentManager(ServiceCreateParameters parameters)
{
    this._parameters = parameters;
    var credential = CertificateAuthenticationHelper.GetCredentials(
        parameters.SubscriptionId,
        parameters.Base64EncodedCertificate);
    this._computeManagementClient = CloudContext.Clients.CreateComputeManagementClient(credential);
}
 
And the CertificateAuthenticationHelper from Brady’s post:
using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure;

namespace Deployer.Common
{
    public class CertificateAuthenticationHelper
    {
        public static SubscriptionCloudCredentials GetCredentials(
            string subscriptionId, string base64EncodedCert)
        {
            return new CertificateCloudCredentials(subscriptionId,
                new X509Certificate2(Convert.FromBase64String(base64EncodedCert)));
        }
    }
}
Posted on Thursday, September 18, 2014 12:37 PM Unit Testing , UI Automated Testing , Build Tools , Windows Azure | Back to top


Comments on this post: Checking the Status of a Cloud Service with Azure Management API

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Aligned | Powered by: GeeksWithBlogs.net