Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manage my Azure Cloud Services using native C# API?

Tags:

rest

c#

api

azure

I would like to manage my Azure Cloud Services programmatically.

I am aware of the REST API but I am wondering if the is a native C# API available just like there is with Azure Storage.

REST API - Operations on Hosted Services: http://msdn.microsoft.com/en-us/library/windowsazure/ee460812.aspx

Or do I need to wrap the REST API myself as described in the post below?

Azure - Cannot programmatically perform VIP Swap: Azure - Cannot programmatically perform VIP Swap

Thanks.


Edit:

The CSManage suggestion helped me a lot.

You can reuse the ServiceManagement project and write your own client (instead of CSManage).

Use the ServiceManagementHelper to setup a channel to execute the commands.

Example:

    public static string SubscriptionId { get; set; }
    public static string CertificateThumbprint { get; set; }

    public static X509Certificate2 Certificate { get; set; }

    private void button1_Click(object sender, EventArgs e)
    {
        SubscriptionId = ConfigurationManager.AppSettings["SubscriptionId"];
        CertificateThumbprint = ConfigurationManager.AppSettings["CertificateThumbprint"];

        X509Store certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
        certificateStore.Open(OpenFlags.ReadOnly);
        X509Certificate2Collection certs = certificateStore.Certificates.Find(X509FindType.FindByThumbprint, CertificateThumbprint, false);
        if (certs.Count != 1)
        {
            MessageBox.Show("Client certificate cannot be found. Please check the config file. ");
            return;
        }
        Certificate = certs[0];

        // List Hosted Services
        var channel = ServiceManagementHelper.CreateServiceManagementChannel("WindowsAzureEndPoint", Certificate);
        var lhs = channel.ListHostedServices(SubscriptionId);
        foreach (HostedService hs in lhs)
        {
            MessageBox.Show(hs.ServiceName);
        }
    }
like image 967
Simon de Kraa Avatar asked Nov 21 '12 14:11

Simon de Kraa


People also ask

Does Azure support C language?

C and C++ with Visual StudioDevelop C++ Windows, Linux, Mobile applications and games using Azure cloud services in a powerful, rich development environment using Visual Studio.

What are Azure native services?

What are cloud-native applications? Cloud native applications are built from the ground up—optimised for cloud scale and performance. They are based on microservices architectures, use managed services and take advantage of continuous delivery to achieve reliability and faster time to market.

Do you need C# for Azure?

You'll also need know an Azure supported language: C#, PHP, Java, Python, or JavaScript.

What is Azure in C#?

Azure Functions is the serverless compute offering in the Microsoft Azure cloud. Essentially, “serverless” means you don't even need a virtual machine to run an Azure Function. Azure Functions are just an implementation of platform as a service (PaaS), one that is based on an event-driven programming model.


1 Answers

As of October 2013 there is a set of C# libraries that wrap the Windows Azure Service Management REST API.

It's available in nuget under the package name Microsoft.WindowsAzure.Management.Libraries.

The blog posts here and here give a bit of an overview and the documentation can be found on MSDN.

As the question asks, these libraries allow you to manage services (create deployments, scale deployments, perform vip swaps etc.) rather than interact with blob / table storage.

like image 148
Simon Ness Avatar answered Oct 28 '22 00:10

Simon Ness