Quantcast
Viewing all articles
Browse latest Browse all 28

How-to deploy application to Windows Azure Compute Emulator with CSRUN

It’s a pain that everytime that I want to start a Windows Azure application, I must first start Visual Studio and start the debugger. In this post I will describe how to start an application in Windows Azure Compute Emulator withoug using Visual Studio debugger. This will work for an application that is a Web Role or Worker Role. There are multiple ways to do this, but I believe this may be the simplest.

In this post I will start from the very begginning of creating a new Windows Azure Cloud Service project and creating a default ASP.NET MVC 4 website. If you want skip all the setup and get to the meat of csrun, then scroll to the bottom of the post.

Things Needed

  • Visual Studio 2012
  • Windows Azure SDK

Let’s get started.

First open Visual Studio 2012 and created an Windows Azure Cloud Service project . Then select ASP.NET MVC 4 Web Role.

Image may be NSFW.
Clik here to view.

 

I changed the name fo the ASP.NET MVC 4 website to “MyWebsite”

Image may be NSFW.
Clik here to view.

 

Since we want this to be a working project, select “Internet Application”

Image may be NSFW.
Clik here to view.

Once you finished the wizard there should be 2 projects created within a solution. For me, my two projects are “AzureSample” and “MyWebsite”

Image may be NSFW.
Clik here to view.

 

That’s all we need to do to get the project up and running. Before we run this application its import to notice that in the AzureSample directory there is no directory called “csx”. The “csx” directory is need to run the application without using Visual Studio and the debugger. It’s somewhat a catch-22 situation in that we need to debug the application once to create the “csx” directory.

Image may be NSFW.
Clik here to view.

If we run (F5) the application through Visual Studio, Visual Studio will package and deploy the website to Window Azure Emulator. Once this is completed you should notice that the “csx” directory has been created.

Image may be NSFW.
Clik here to view.

Also during this time Visual Studio has started the Windows Azure Emulator. The status of Azure Emulator will be displayed if you hover your mouse over the Windows Azure Emulator Icon in the System Tray.

Image may be NSFW.
Clik here to view.

If you right click the Azure Emulator Icon, you can select “Show Compute Emulator UI”. This will open the Windows Azure Compute Emulator UI

Image may be NSFW.
Clik here to view.

In the Windows Azure Compute Emulator, you can see that our Application was been installed and is running at 127.0.0.1:81

Image may be NSFW.
Clik here to view.

By using your browser and the URI identified in the Azure Compute Emulator, you should be able to navigate to the page.

Image may be NSFW.
Clik here to view.

Stop the debugger in Visual Studio. This should kill the application running in the Windows Azure Emulator.

Image may be NSFW.
Clik here to view.

All we did here was confirm that the website worked. Now that the “cts” directory is created and we are confident the website works, lets start the website without using Visual Studio and the debugger.

For presentation purposes I’ve closed Visual Studio.

Now starts the Windows Azure Command Prompt. I believe this should be run in administrator mode.

Image may be NSFW.
Clik here to view.

Image may be NSFW.
Clik here to view.

In the console navigate to the directory that contains the AzureSample. For me, the path is C:\Projects\Samples\Azure\AzureSample\AzureSample

Once you have navigated to the directory, run “dir” to get a directory listing. In the results there should be a directory call “csx” and a file with the extension of “local.cscfg”. This is the information we need to start the application in Windows Azure Emulator

Image may be NSFW.
Clik here to view.

Now in the console we will run csrun with a 2 parameters. The first parameter will identify the location of the package. The second parameter will identify the configuration file to use. For this example the package is located in “csx\debug” and the configuration file is called “serviceConfiguration.Local.cscfg”.

In the console execute csrun with the two parameters. For me the command is “csrun csx\debug ServiceConfiguration.local.cscfg”

Image may be NSFW.
Clik here to view.

This will install the application into Window Azure Compute Emulator. The results of the command identifies that the website will be running at 127.0.0.1:81.

We can see that in the Windows Azure Compute Emulator that the website is running.

Image may be NSFW.
Clik here to view.

Now in your browser of choice navigate to 127.0.0.1:81 and the browser should display your page.

Image may be NSFW.
Clik here to view.

I hope this helped.

 


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 28

Trending Articles