Publishing Windows Azure Solutions from VS2012


I will publish the MVC 4 solution which we created in the previous post to the Windows Azure. You should have a Windows Azure account from http://www.windowsazure.com. Once you have got your account after entering the payment information and selecting your subscription you can see the Windows Azure portal as below.

1

To deploy our application to Windows Azure we would require the following steps.

1- Create a new Hosted Service.
2- Create a new Storage Storage Account.
3- Create and configuring management Certificates.
4- Pre-publishing steps.
5- Publishing the solution from Visual Studio 2012.
6- Changing runtime configurations after deployment (Not mandatory for publishing)

1- Create a new Hosted Service

To deploy our application containing a Web and a Worker role we would need Storage Service and Hosted Service. First we would create a Hosted Service which is to host our Web and Worker role services. Click on New Hosted Service and the below popup would open. In the dialog you can choose a subscription and enter the name of your Hosted Service. Choose a URL prefix for your service I am naming it HelloWorldAzureAbdul. For the solution I am creating and affinity group which is going to have my Hosted Service in the East Asia Data Center region.

2  3

Choose Do not deploy and click OK. You can see in the Hosted Services we have a Hosted Service called “HelloWorldAzureAbdul” which we created.

4  5

2- Create a new Storage Storage Account

To create a new storage account go to “Storage Accounts” and then on the top click “New Storage Account”. In the dialog give choose a subscription and enter the URL. I will enter the same URL helloworldazureabdul and choose the affinity group which was created in Step 1. Click OK and then you can see that the new Storage Account is created.

3

3- Create and configuring management Certificates.

To enable Visual Studio deploy the solution to my Windows Azure solutions we need to configure the management certificates so that I can enable my account to accept deployment from my machine which has the SSL certificate. In Visual Studio go to the Server Explorer (CTRL+W, L) where you can see the Windows Azure Compute and Windows Azure Storage Node which is installed by the Windows Azure SDK.

Right Click “Windows Azure Compute” and Click “Add Deployment Environment”.

6

Since I don’t have any existing deployment environment Click “Manage”. In the Authentication Settings dialog click “New” which would ask you to create a new certificate on your local machine.

7  8

Enter a friendly name of the certificate, I would name it “HelloWorldAzureAbdulCert” and then click OK. You can enter the name of these credentials I would name them “HelloWorldAzureAbdulAccount”. In the second textbox you need to enter your subscription ID which you can get from the portal.

9  15

In the above dialog click “Copy the full path” of the certificate you created. Click OK and you will be able to see the Account with the Solution Environment.

16

In the management portal go to Management Certificates and select your subscription. Then on the top click “Add Certificate”.

11

Click Browse to upload the certificate from your local PC. Since we already copied the full path of the certificate created we can just paste it and click Open.

12

Click Ok and then in the portal you will be able to see the uploaded certificate.

13  14

4- Pre-publishing steps

Before publishing the application to the cloud we need to make sure about the dependencies that are locally present on the machine but they won’t be available in the cloud. We need to check for the referenced assemblies connection strings and application configurations. If there are any third party assemblies or your local project assemblies so set the Copy Local property of the assemblies to True.

If you look at the worker and web role settings in the Windows Azure project it is having connection strings being used by diagnostics so you can uncheck the option to remove these diagnostic connection strings so that there are no dependencies.

5- Publishing from Visual Studio 2012

Now that everything is set up we can publish the solution to the cloud from VS. Right click the Windows Azure project and then click Publish. It will open the Windows Azure publish wizard in the first step Choose the subscription.

20

21

Click Next and in the Common Settings tab choose the cloud service solution, choose the staging/production environment. In the Advanced Settings tab label the deployment and select the Storage Account. Click next to finish the publishing steps and go to the summary page.

22

23

24

The deployment will start and the deployment progress can be seen in the Windows Azure Activity log window in Visual Studio.

27

After sometime you can notice in the Server Explorer that the Web and Worker role VM’s are created in the staging environment of the deployment but will be in the stopped state.

28

In the Server Explorer after some time it can be noticed that the VM’s are starting.

29

Once the deployment is completed the status will be updated to completed and the Website URL with a GUID will be created.

32

You can then go the the website URL generated and see the application. In the portal you can see that the solution is deployed.

33

34

6- Changing runtime configurations after deployment.

In the previous post we added a configuration key “Message” so that it can be changed after deployment into the cloud and re-deployment can be avoided. We can change the configuration from the portal, Select the Deployment and then click Configure in the top menu. A dialog having the configuration XML will appear in which the Message value can be changed.

36

After changing the value click OK as shown below and the changes will take effect in each instance of the web role.

37

38

You can refresh the browser where the application in the cloud was opened and see the updated message.

39

One Response to Publishing Windows Azure Solutions from VS2012

  1. Paul says:

    Reblogged this on venneker.net.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 139 other followers

%d bloggers like this: