Freigeben über


Cloud deployment on a developers finger tips

New features and Cloud Capabilities at a Developers’ Finger tips

Introduction:

The Azure Tooling team within VS has provided a new set of templates that make it easy for a Developer or Development team to programmatically control the spin up and tear down of multiple VMs in a controlled fashion.

Benefits and Applications

The kinds of scenarios that some DEV team or ISV can put this to use are quite wide and varied. As mentioned above a DEV team can have a solution maintained as CODE just for spin up and deploy, and share it within the team do launch the setup and teardown on demand OR on schedule.

An ISV or another product group could take this and package a configurable (in terms of the number and types of VMs) deployment solution that can then be used by their end users or customers to spin up a desired configuration on demand or on schedule. What would earlier be a series of operations initiated through the portal or PowerShell can now be done with a single click when you finally produce a tested and working EXECUTABLE that can then be distributed – of course the subscription ID and the settings file which I show below that have been pulled and hard coded would have to be fetched from the end user programmatically (which is fairly trivial to do) as input to the executable.

One can also think of something like the Lab Manager for TFS kinds of solutions being entirely wrapped up using these kinds of constructs.

HOW TO

We are going to explore the “Deploy and Manage Virtual Machine” template that comes with Azure SDK 2.5 installed on top of VS 2015 as shown below.

Open up VS 2015 Preview and launch a project as shown below.

clip_image002

Solution Folder

clip_image003

Getting your Client authorization in Order

Now as you know to do any operation from any sort of Client against the Azure platform, you need your publish settings file to be on the client (be it PS, Portal or VS) to communicate back to Azure in a secure manner. So first download the publish settings file and store it in your Solution Folder.

Getting the publish settings file

Open your program.cs file and click on the link below to download the settings file. I like to keep it within my VS solution folder and so saved it right in the folder structure of my solution. Change the path file as shown below.

clip_image005

Further Exploration

The files Program.cs and VMManagementController.cs contain methods and parameters that you can tweak and configure for Windows based VMs. This can be enhanced to do the similar type of operations for Linux VMs also.

VMManagementController.cs file uses various methods as shown below, and it is quite possible to add or to modify the existing methods to enhance the default capability provided. When the Controller code gets called in from main() in Program.cs

image

Examine the various methods in here to modify and add to the VM customizations and parameters you can to the defaults.

Publish your deployment solution as a WebJob

clip_image001

Choose your run-mode as shown below.

clip_image003

This will create a publish settings file as shown below.

clip_image005[6]

clip_image007clip_image009

clip_image010

In your build output Windows you can see the following flashing through which compiles, builds and then if successful then goes on to publish the bits to your Azure Website to run as a Web Job.

clip_image012

clip_image013

Now to run the App OR launch the Web Job

 

You can now run this solution right from within VS or from within the portal.

Running from the portal

To run from the portal you can login to the Azure Portal and navigate to the Web Job and initiate it from there, is you have set it run on-Demand as I have done.

Navigate to your Azure portal and expand on the WebApplication which you had chosen during the publish phase. You will see WebJobs that you had deployed earlier.

clip_image002[4]

Click on that to take you to the Web Job as shown below.

clip_image003[4]

clip_image004

Click Run to Start the WebJob. Once it runs to completion you should see your VMs up and running.

Running from VS

To run from within VS just start like any normal VS project where you click on “Start” or F5 or Ctrl+F5 and you get the familiar and convenient experience of setting break points and debugging if needed.

The following are a series of screen shots that will show up on the Console when you launch from within VS. Note that you can customize this set of messages that pop up on the Console.

clip_image006

clip_image007

Leaving this AS-IS you should now be RDP this to your VM. You could come back and shutdown the VM.

Conclusion

Now you might ask what’s the big deal between spinning up VMs like this and as opposed to clicking through either the Portal or from the Server Explorer in VS. The difference is the power you can use to leverage a set of VMs customized to an N-Tier application and exploring scenarios when you can deliver customized solutions on top of the bare VM creation ability from either the portal or PS or Server Explorer. The scenarios are endless for an ISV to exploit a la TFS Lab Manager or Release Manager, but now directly under the control of your code. This is pretty neat for those with the time and resources to craft solutions for themselves or provide a configurable and customizable multiple VM creation package, especially for an ISV.