Article Level: Beginner
In this article, I try to explain Windows Azure cloud services step by step. This article is a follow up article where I was favoring Windows Azure Virtual Machine vs Cloud Services. But that article had a context of supporting that theory. But Azure cloud services is a marvelous technology but requires a different paradigm shift in thinking. In that respect I am planning to write an article series, where I will try to explain in easy terms of my understanding of Azure cloud services.
I am hoping to write a series of articles on Demystifying Azure with my practical experience.
1. Windows Azure cloud services explained step-by-step (This article)
2. Azure publish or package – What goes in ?
3. Azure cloud services – Do not RDP and make changes (Yet to come)
What is Windows Azure cloud service and why do we need them?
Windows Azure cloud services is an umbrella term that refers to almost all activities that are performed in the azure environment. That is the reason it gets confusing that when we talk about “Cloud Services”. To understand this better, lets take a look at the following scenario
1. A user creates a Windows Server 2008 machine and puts his small html site in Azure. The user has created a “cloud service” here.
2. A user creates two machines and installs a ASP.NET web site with a SQL server backend. This is also a “cloud service”.
3. A virtual network that connects three or four different machines inside Azure with a complicated Active Directory installation that syncs up users with on-premise Active Directory providing Single Sign on, this again is a cloud service.
So I hope the wide spectrum of activities described above being called as Cloud Service must give you the idea of what a “cloud service” is, it is a collective term.
How can I implement my solution in Windows Azure cloud services
Now that we know what “cloud service” means, we can look at how to implement a so called “cloud service”.
So, you have a asp.net web forms or MVC project that you would like to host in Windows Azure cloud service and get “cloudified”. I have tried to detail a simple step by step approach of the process below.
STEP 1: In Visual studio, right click on the Solution –> Add New Project – choose Cloud project. Give the project the name “MyASPNetProject.Cloud”
STEP 2: After you have added a cloud project, You will be prompted to choose couple of existing projects for roles, don’t choose any, click OK. The reason being, our ASP.NETProject is the project that we need to link with.
STEP 3: The project will get added in the solution. Roles section will be empty because in the previous step we did NOT choose a new project.
STEP 4: Right click on Roles and choose - “Web Role project in solution”. That command should open up a window like below. Notice that Visual Studio figures out that the asp.net project that you have is a candidate to be created as a “Web Role” ( we will decipher these terms at the end of the article, right now just read them as what it is – Web role). Choose that and click OK.
STEP 5: The cloud project has got added to the solution in addition to existing ASP.NET project. The roles which was empty earlier now has an entry pointing to the asp.net project.
Notice that the cloud project comes with its own set of files and structure. Let us explain each one of them
1) Roles: Cloud services most popular roles are Web Role / Worker role. Web roles are windows server machines with IIS. Worker roles are windows server machines without IIS. Worker roles are optimized for running continuous jobs in azure environment, while web roles are for running web sites.
2) ServiceConfiguration.csfg – There is a cloud version and local version. Visual studio allows you to simulate a azure like environment including multiple instance of web role and worker role in your laptop or desktop. So a “local” cscfg file has elements of configuration for that. A cloud environment is what visual studio uses whenever you publish or package a package for creating a cloud service
3) ServiceDefinition.csdef – This is the file where you specify the hardware for your installation. Small / medium / large, how many instances etc.
STEP 6: Now our application is Azure “publishable”. You should either have a Azure account already (there is a free trail that Microsoft provides for 3 months with more than enough timeline and compute hours) or should have paid version. Whichever is the case we need to download the credentials and keep it ready. Login to the azure portal. There must be a left icon called “Cloud Services”. If this is the first time you have registered and logged-in, thus must be empty.
STEP 7: On the Cloud project, right click – click Publish. You also see a package option, but we will deal with that later. “Publish” menu is a magical menu in Visual studio that takes care of publishing for you. It creates a package in azure format and then installs it for you. The publishing activity requires certain input parameters to be provided at every stage. It is a three stage process
Stage 1: You will be prompted to enter / choose your credentials for your azure subscription. Your screen would look like this
If you don’t see one already, then click on “download credentials” (highlighted), log on azure site, download the file and then import the file using the Import button. Click Next on the Wizard.
Stage 2: You will be shown a screen like this.
Let us break this screen in to parts -
Cloud Service - You can see that you are now creating a “Cloud Service” here. At this stage, you have to note that you are creating a “cloud service” only but are not configuring any hardware in to that yet, (remember the initial part of the article – umbrella term). Choose the region closest to you and give it a decent name. This name is very very important to give it correct instead of test or temp etc as this name is what your clients or any of your users would be accessing, so choose a good name. Say – InvoiceSystem. This name would eventually become
Environment – You can choose to put in “Staging” or in “production”. Briefly, staging means an environment that gets a GUID as a URL (xxyyzzaabb.cloudapp.net kinds) which you choose to use as a QA environment. Once your testing is over, you can simply do a SWAP of your environments making it an ideal situation for test builds and production builds. Right now we can choose “production”
Build Configuration – This is easy, release or debug, production builds are always RELEASE. no two ways about it.
Misc Configuration items – Cloud and local are the options for service configuration. Obviously it is cloud profile.
Enable Remote Configuration – Enable this so that you can Remote desktop to the installed machine and check your installation and perform other tasks
Advanced Settings - The second tab has advanced settings, create a “storage account” here. A storage account is a basically a blob based place holder that will storage your installables.
STEP 8: Verify all the settings in the next screen and click on “Publish”
At this stage wait it out for few minutes (depends on how big is your original asp.net solution). Once done Visual studio would give you the URL and ask you to browser for the site.
Refer to the next articles in this section to get more details on “How it works”
Happy Coding. Please feel free to leave your comments and suggestions.