domgreen

The Geek Will Inherit the Earth

  • UK MSDN Flash – 4th November 2009

    • 15 Nov 2009
    • 0 Responses
    •  views
    • MS Build MSDN UK MSDN Flash Windows Azure
    • Edit
    • Delete
    • Tags
    • Autopost

    Last week I had an article featured in the UK MSDN Flash magazine, the article was describing how I have set up your automated builds to deploy to Windows Azure using the recently released management services.

    Media_httpdomgreencom_alcbo

    Media_httpdomgreencom_xvhlm
    The article “Deploying to the Cloud as Part of Your Daily Build” can be found here.

    You can also find out more information and subscribe to the UK MSDN Flash here.

    • Tweet
  • Deploying to the Cloud as Part of Your Daily Build

    • 30 Sep 2009
    • 0 Responses
    •  views
    • Azure Cloud Computing Deployment MS Build Windows Azure csmanage cspack
    • Edit
    • Delete
    • Tags
    • Autopost
     

    I have recently been working on a big Azure application that we have been wanting to deploy to the cloud and test, to make sure that no unexpected bugs occur whilst the application is in the wild and give the opportunity to see how it performs.

    Now the big problem has been deploying our application to the cloud every time we wanted to update the application online, we had a dev sit there and manually publish the service, upload the package and initialize the instances. This obviously wasn't great as one of the developers on the team would have to take time out from his tasks / bugs to upload the application.

    However, the Azure team came through with some great releases just over a week ago that would allow the management of our services via an API. As soon as I read the blog post announcing the Windows Azure Service Management API I knew that my prayers had been answered and we would be able to automate deployment of our application out to the cloud. This surprisingly was much easier to understand and implement than I imagined as a sample called csmanage.exe was included with the release giving a hook into all of the API’s (documentation).

    The most time consuming part turned out to be wrapping the calls to csmanage.exe into build scripts and watching a number of builds and deployments fail before getting it right (no one likes to wait 15mins only to see a red light).

    So here’s what I did to get our application deploying on the daily build:

    Seting up the Service

    Setting up the service requires you to upload a certificate to your Azure login, this can either be done with the following handy command line argument:

    Or use Eric Nelson’s walk through “Using IIS to generate a X509 certificate”.

    Now we just need to log into the portal and upload the certificate, taking note of your Subscription ID and certificate thumbprint.

    Media_httpdomgreencom_pfcmg

    Configure csmanage.exe

    With this information we can now configure the csmanage tool to talk with the service management API.

    Media_httpdomgreencom_iliyl

    Packaging the Cloud Service

    When deploying prior to the release of the management API I would normally right click the Cloud service within Visual Studio and let it handle the packing of the application itself, however during the build we will need to do this automatically. So we can dig out cspack.exe a command line application to package up your solution that was shipped with the Azure SDK.

    When packaging the application we need to give the cspack executable a number of arguments these are, the service definition so that it knows what configuration to expect, any web roles and their containing folder, any worker roles with the folder containing the dll and also the name of the dll and an optional out parameter. I normally use the out parameter to ensure that I have the correct name and location of the package for the next step.

    Uploading cspkg to Azure Storage

    When deploying with the csmanage.exe we need to ensure that the packaged solution is available in blob storage on the same account you are deploying to, to do this I have created a simple command line application that takes the cspkg file and puts it into a folder called “packages” in our storage area.

    Using csmanage.exe

    Now that we have our package in Azure storage and csmanage.exe configured we can use the management API to call out to our service and deploy to Azure.

    I first suspend and delete any service that is currently running:

    This leave me safe in the knowledge that the creation of a package will not fail due to a running service.

    Now the important part using csmanage.exe to create a deployment in our hosted service, within this command I am selecting the hosting area I wish to create the deployment, the production slot as well as the location of the package (blob storage) and any configuration that will be used in the deployed service.

    Once the service is successfully deployed we can set the status of the deployment to a running state and allow it to initialize itself.

    Once the deployment is fully initialized users can start using the application.

    Creating Build Targets

    With the correct commands figured out and correctly deploying my application to the cloud I decided to write some build targets to do this during our daily builds. To do this I used the msbuild exec command (I know this is probably really ugly but it gets the job done, well at least until the Azure boys give some built in tasks).

    The only problem I found with this that the csmanage.exe will return exit codes and so the exec command will need to ignore these, or will treat them as errors during the build.

     

    Multiple Deployments

    On the current project we are actually deploying the application to a number of different sites for test, performance etc. so have also had to create a number of scripts to ensure that the endpoints are correct for each of the deployments. Added to this we needed to check that the csmangae.exe and the cloud apps configuration (cscfg) are set up correctly using the sdc tasks and their xml setters to get this working.

    Now at the end of each day the latest iteration of our application is uploaded and deployed to Azure, leaving us devs to be happy coders and not worry about deployment :) .

    • Tweet
  • About

    By day a virtual warrior, hunched over a keyboard cranking out line after line of code at Huddle, living the East London tech dream at Silicon Roundabout. We are an Enterprise collaboration tool that will revolutionise how your company collaborates, shares and operates, we are taking the fight to Microsoft SharePoint, we are David and we're taking on Goliath.

    However, by night this pasty geek escapes his keyboard and monitor with the attempt to get fit. I train at one of the greatest gyms in London, Thames CrossFit. CrossFit is not like other gyms its a lifestyle, and as the guys at Thames say you must be prepared to work hard.

    I also run with the great Run Dem Crew a Shoreditch based running family who run the mean streets of London by night. RDC is a mecca for runners, and creatives alike.

    With all this training its bound to get hard, its bound to be tough but its certainly worth it when you achieve something great and make friends along the way.

    So remember, "Pain is temporary but victory is forever".

    77080 Views
  • Archive

    • 2011 (13)
      • June (2)
      • May (5)
      • April (6)
    • 2010 (3)
      • April (1)
      • January (2)

    Get Updates

    Subscribe via RSS
    TwitterBuzz