Web UI looks good and pretty but if you really want to get work done at scale, manage, automate and administer: command line is your way. As a command line junkie from the UNIX world I thought of exploring what Azure PowerShell had to offer. And boy, I was quite blown by the ease of use, functionality and flexibility it comes with. Through this tutorial series, I will take you through various scenarios and functionality on Azure that is made easy using Azure Power Shell
Till now, I have covered the following services in Azure and how we use Power Shell to manage those:
In this section I will cover some key Cloud Service concepts and how we can manage cloud services using Azure Power Shell. Cloud services are generally the preferred mode of development for decoupled, multi tiered applications that can scale independently of each other. The two primary components are web role and worker role. The web role can be thought of as the web front facing interface where as the worker role can be thought of as a backend process role and the communication between them can be accomplished using either Storage queues or Service buses.
As always, the first thing that needs to be done is to assign a subscription in the power shell console:
There are 2 main configuration files for Cloud Services. The configuration file (.csfg) and the cloud service definition (.csdef) file. These are xml formatted files and generally contain configuration parameters such as the number of roles, the number of instances supporting the roles, etc. You can either set the number of instances in the (.cscfg) using the element “Instance count” or using the power shell as shown:
Note: for the SLA, the instance count should be at least 2 to ensure high availability.
If you were to create custom domains for your cloud service, you could create the A record or CNAME record by getting the required values either from the management portal in the ‘quick glance’ section or you could obtain it using the following commands:
Reserved IPs are often useful if you would want to preserve the IP of a cloud service in case you delete one and would want to reuse the IP for the cloud service. Currently it is not possible to add an ip address to a Reserved Ip list, hence you are supposed to create the reserved IP before you create a cloud service to use the IP. Also important thing to note is that you can only create reserved IPs through the powershell. The following commands can be used to create and use a reserved IP:
Now if you want to use the reserved IP in your cloud service you will need to add the <ReservedIP name> element in the < NetworkConfiguration> element of the configuration file (.cscfg).
If you want to configure SSL for your cloud service, the thumbprint will be incorporated in the service definition file (.csdef) and will appear in the <certificates> element of the configuration file (.cscfg). Now you can add the certificate file either using the Management portal or you could use the following commands to add the certificate to your cloud service:
Deploying and Publishing a cloud service generally involves creating a packaged version (.cspkg) of your cloud service that can be uploaded on Azure. Packaging can be done in several ways and one of them is by using the CSPACK command line tool that comes with the Azure SDK. Once the package is created, publishing can be done using the management portal, visual studio or PowerShell. The following commands can be used to publish the cloud service:
Through this post I covered some of the options that can be explored using PowerShell for Cloud Services. Cloud Services including web and worker roles is powerful and gives the flexibility to accomplish a lot. The Management Portal has a lot of options and certain functions such as scaling, monitoring and diagnostics that cannot be accomplished using PowerShell and should definitely be explored. One more key topic is Service Bus which is important for communication between the web and worker roles. The various functions such as Queues, Topics, Relays and Event hubs have a lot to offer in cloud Services and should be explored.