Home > Blogs
Undoubtedly by now you have heard of AzureFest, with any luck you have been out to one of the events [if you live in the GTA]. For the rest of you, that haven’t been able to experience the event, I wanted to take the opportunity to introduce you to what AzureFest is and why you might be interested in the event itself.

What is AzureFest?
At it’s core AzureFest is a talk that focuses on a few barriers to Windows Azure Adoption including Pricing, Registration, Platform Confusion and Coding/Deployment. This is not your Grandma’s Windows Azure Presentation, It includes both a lecture and a hands on component which is rare for a Community Event.
Why Talk Pricing?
Simple, pricing is the first question that I get asked at the end of every presentation that I’ve done to date, so why not talk about it first? Pricing goes hand-in-hand with the Platform, which means not only do you get to understand what the Windows Azure Platform consists of, but you also get an understanding of what it will cost as well. Finally, It would be rather irresponsible not to talk about the costs of Windows Azure when the first Hands-on-Lab is a walkthrough of the registration process.
What Will I Learn?
Besides the Overview of the Platform and the Pricing Strategies, each attendee who participates in the Labs will learn:
-
How to Register for a Windows Azure Platform Subscription
-
How to Create, Manage, Configure and Leverage a SQL Azure Database
-
How to Create and Configure a Windows Azure Storage Service Account
-
How to Create & Deploy a Project to Windows Azure Compute
-
Attendees will also learn some of the gotcha’s around the Tool Installation/Configuration Process and some strategies on how to debug your cloud based solutions both on premise [using the Compute Emulator] and “In The Cloud”.

Bonus… We’re giving it away!
In the spirit of growing adoption of the Windows Azure Platform within Canada [or any country for that matter], ObjectSharp is releasing the content as an Open Source Presentation. This means it is FREE for anyone to download, learn and/or deliver.
If you are interested in doing an AzureFest presentation in your area, download the Resources for AzureFest. The resources include:
- An AzureFest Slide Deck
- Hands-on-Lab Kit [Ready to deploy cspkg and cscfg files]
- Modified NerdDinner Source Code for Hands-on-Lab
If you have specific questions about delivering an AzureFest presentation, or need clarification on the content, please direct your questions to me via twitter.

Do you live on the East Coast of Canada? Interested in getting to know more about the Windows Azure Platform? I’ve got a surprise for you! AzureFest is coming to a User Group near you!
Moncton
May 6th – 6:00pm – 9:00pm Register
On May 6th I start the Tour at the Moncton Chapter of Dev East User Group. User Group Lead Sebastein Aube [@sebaube] hosts #AzureFest at the Greater Moncton Chamber of Commerce in the Board Room on the First Floor.
Event Sponsored by MSDN.
Fredericton
May 7th – 9:00am – 12:00pm Register
After a bit of a Road Trip and a quick power nap, I’ll be off to the Fredericton .NET User Group. User Group Lead Andrew Trevors hosts #AzureFest at the University of New Brunswick Campus in the Information Technology Center.
Halifax
May 8th – 1:30pm – 4:30pm Register
My final stop on the tour will be in Halifax. The Halifax Chapter of Dev East User Group lead by Shawn Duggan [@shawnduggan] hosts their #AzureFest at The Hub on the Second Floor.
Want to hold your own AzureFest?
If you want to host an AzureFest of your own ObjectSharp has released the Content for AzureFest as an Open Source Presentation, you can download the content off the AzureFest Website.
Don’t’ really know what AzureFest is all about? Read about AzureFest and our official release of AzureFest as an open source presentation on the Canadian Developer Connections Blog.
In this post we will look at how to write a piece of code that will allow your Application to be Environment aware and change where it receives it’s connection string when hosted on Windows Azure.
Are you looking to get started with Windows Azure? If so, you may want to read the post “Get your very own Cloud Playground” to find out about a special offer on Windows Azure Deployments.
State of Configuration
In a typical ASP.NET application the obvious location to store a connectionString is the Web.config file. However when you deploy to Windows Azure the web.config gets packed within the cspkg File and is unavailable for configuration changes without redeploying your application.
Windows Azure does supply an accessible configuration file to store configuration settings such as a connectionString. This file is the cscfg file and is required to upload a Service to Windows Azure. The cscfg file is definitely where you will want to place the majority of your configuration settings that need to be modified over the lifetime of your application.
I know you’re probably asking yourself, what if I want to architect my application to work both On-Premise and in the Cloud on one Codebase? Surprisingly, this is possible and I will focus on a technique to allow a Cloud focused application to be deployed on a Shared Hosting or On-Premise Server without the need to make a number of Code Changes.
Obviously this solution does fit within a limited scope, and you may also want to consider architecting your solution for cost as well as portability. When building a solution on Windows Azure, look into leveraging the Storage Services as part of a more cost effective solution.
Cloud Aware Database Connection String
One of the most common Configuration Settings you would like to be “Cloud-Aware” is your Database Connection String. This is easily accomplished in your application code by making a class that can resolve your connection string based on where the code is Deployed.
How do we know where the code is deployed you ask? That’s rather simple, Windows Azure Provides a static RoleEnvironment Class which exposes a Property IsAvailable which only returns true if the Application is running in either Windows Azure itself or the Windows Azure Compute Emulator.
Here is a code snippet that will give you a rather good idea:
namespace Net.SyntaxC4.Demos.WindowsAzure
{
using System.Configuration;
using Microsoft.WindowsAzure.ServiceRuntime;
public static class ConnectionStringResolver
{
private static string connectionString;
public static string DatabaseConnectionString
{
get
{
if (string.IsNullOrWhiteSpace(connectionString))
{
connectionString = (RoleEnvironment.IsAvailable)
? RoleEnvironment.GetConfigurationSettingValue("ApplicationData")
: ConfigurationManager.ConnectionStrings["ApplicationData"].ConnectionString;
}
return connectionString;
}
}
}
}
Let’s take a moment to step through this code to get a better understanding of what the class is doing.
As you can see the class is declared as static and exposes one static property, this property will either grab the Configuration Setting that is required for the particular environment the Application is Deployed on.
If the connectionString variable has not been previously set a conditional statement is evaluated on the RoleEnvironment.IsAvailable Property. If the condition is found to be true the value of connectionString is retrieve from the CSCFG file by calling a static method of the RoleEnvironment class GetConfigurationSettingValue this searches through the Cloud Service Configuration file for a Value on a Setting with the Name “ApplicationData”.
If the RoleEnvironment.IsAvaliable Property evaluates false, the application is not hosted in the Cloud and the ConnectionString will be collected from the web.config file by using the System.Configuration.ConfigurationManager class.
The same technique can be used to resolve AppSettings by accessing the AppSettings NameValueCollection from the ConfigurationManager class.
Beyond The Basics
There are a few other things you may come across when creating your Cloud Aware application.
Providers, Providers, Providers
ASP.NET also contains a powerful Provider model which is responsible for such things as Membership (Users, Roles, Profiles). Typically these settings are configured using string look-ups that are done within the web.config file. This is problematic because we don’t have the ability to change the web.config without a redeployment of our Application.
It is possible to use the RoleEntryPoint OnStart method to execute some code to programmatically re-configure the Web.config, but that can be both a lengthy process as well as a very error prone way to set your configuration settings.
To handle these scenarios you will want to create a custom provider and provide a few [well documented] configuration settings within your Cloud Service Configuration file that are used by Convention.
One thing to note when using providers is you are able to register multiple providers, however you can only provide so much information in the web.config file. In order to make your application cloud aware you will need to wrap the use of the provider objects in your code with a check for RoleEnvironment.IsAvailable so you can substitute the proper provider for the current deployment.
Something to Consider
Up until now we’ve been trying to [or more accurately managed to] avoid the need to recompile our project to deploy to the Cloud. It is possible to package your Application into a Cloud Service Package without the need to recompile, however if you’re building your solution in Visual Studio there is a good chance the Application will get re-compiled before it is Packaged for a Cloud Deployment.
With this knowledge under your belt it enables a unique opportunity for you to remove a large amount of conditional logic that needs to be executed at runtime by handing that logic off to the compiler.
Preprocessor Directives are a handy feature that don’t get leveraged very often but are a very useful tool. You can create a Cloud Deployment Build Configuration which supplies a “Cloud” Compilation Symbol. Leveraging Preprocessor Conditional logic with this Compilation Symbol to wrap your logic that switches configuration values, or Providers in your application can reduce the amount of code that is executed when serving the application to a user as only the appropriate code will be compiled to the DLL. To Learn more about Preprocessor Directives see the first Programming Article I had written.
Conclusion
With a little bit of planning and understanding the application you are going to be building some decisions can be made really early to plan for an eventual cloud deployment of an application without the need for an abundance of code being written during the regular development cycle nor is there a need to re-write a large portion of your application if you would like to build the functionality in once the Application is ready for Cloud Deployment. With this said there are still obvious improvements to be gained by leveraging the Cloud Platform to it’s full Potential. Windows Azure has a solid SDK which is constantly and consistently iterated on to provide developers with a rich development API.
If you want to leverage more of Windows Azure’s offerings it is a good idea to create a wrapper around Microsoft’s SDK so you will be able to create a pluggable architecture for your application to allow for maximum portability from On-Premise to the Cloud and ultimately between different cloud providers.
Happy Clouding!
This article also appears on SyntaxC4's Blog.
In my last two posts in this series [Part 1, Part 2] we have created a Start-up script to install PHP on our Windows Azure Web Role, we have created the necessary Cloud Service Definition and Cloud Service Configuration files.
In this post we’ll look at how to use the command-line tools for Windows Azure to Package our Deployment and how to deploy that package to the Windows Azure Platform Portal.
Packaging a Windows Azure PHP Deployment
I know what you’re thinking “Hold up, we need to package our deployment? What ever happened to good old FTP?”
FTP works great for a single point of access, but we’re looking to be able to rapidly deploy our application across many servers in a matter of minutes. Microsoft uses these packages for just that purpose, rapid deployment.
What is the Cloud Service Package (.cspkg)
The Cloud Service Package is essentially a Compressed file which holds your application, the Cloud Service Definition and a number of other files required by Windows Azure. These files are encrypted by the tool incase the package is intercepted when being transported over HTTP.
You are able to leave the cspkg unencrypted using one of two methods. I would suggest using the Environment Variable [setting _CSPACK_FORCE_NOENCRYPT_ to true], mostly due to the fact that there is a good chance you won’t be using MS Build for your PHP Application.
Setting an Application Variable
Open the Control Panel. Find and Click on System.

Click on the Advanced System Settings link in the Right hand Menu. This will open the System Properties Dialog.

Click on Environment Variables…

Then on New…

Creating a Build Script to Automate Deployment Packaging
As a developer, it is a good idea to optimize repetitive tasks in order to be more productive. One of these optimization points that you should be looking at is Build Automation. With PHP being a Scripting Language and does not need to be compiled this is a very simple thing to accomplish. Here is how simple your “Build Script” can be.
cspack ServiceDefinition.csdef
In our previous post we added the Windows Azure Command-Line Tool Path to our System Path. This enables the above script to execute the tools and create the Cloud Service Package.
To make your build script more powerful, you could add some additional functionality like executing a powershell script which leverages the Windows Azure Powershell CommandLets to deploy your latest Build to your Staging Environment in Windows Azure.
Deploying your Service Package to Windows Azure
There are many different means to getting your Windows Azure Project in to the Cloud. Once you’ve had a chance to evaluate the different methods I would suggest using the method that you find most suitable for you.
Here is a list of different methods of Deploying to Windows Azure:
Note: Barry Gervin and I have put together a video on how to deploy using the Windows Azure Platform Portal.
- Deploying using Visual Studio
Test Startup Scripts Locally using RDP
As developers we all know that testing will always win out over trial and error, this is no different when creating a startup script for Windows Azure. Be sure to save yourself from pulling out your hair by testing you’re the executable files that will be called by your start-up tasks by RDPing into a Compute Instance.
I’ve created a few blog posts that will aid you in setting up RDP into Windows Azure:
Note: Installers that have a “Quiet Install” option (/q) in their command-line switches, are your absolute best friend. Otherwise, trying to mimic a users acceptance to a Eula or other dialog is rather difficult. WebPI allows us to accept a Eula with a switch (/AcceptEula)
This article also appears on SyntaxC4's Blog.
As a Software Developer we have many options when it comes to the tools that we put in our tool belt. One thing that I’ve found exceptionally useful over the years are Virtual Machines, not only Virtual Machines, but having a tailored environment to what you’re Developing.
With my focus on the Cloud I thought it would be useful to continue the trend of Building out a Virtualized Environment that’s Tailored to my work that I’m doing in the Windows Azure Platform. I’ve compiled a list of the Tools and SDKs in which I have found the most useful while working on projects for Windows Azure.
Operating System
Note: Windows Server 2008 R2 is a Handy OS to have on a Virtual Machine within your environment if you expect to have to use the VM Role in Windows Azure.
Desktop Backgrounds
Windows Add-Ons
Development Environment
IDE
SDKs
Extensions
Assessment & Optimization
Management & Debugging
Free
Paid
Code Samples
Bookmarks
This article also appears on SyntaxC4's Blog.
In the last post of this Series, Installing PHP on Windows Azure leveraging Full IIS Support: Part 1, we created a script to launch the Web Platform Installer Command-line tool in Windows Azure in a Command-line Script.
In this post we’ll be looking at creating the Service Definition and Service Configuration files which will describe what are deployment is to consist of to the Fabric Controller running in Windows Azure.
Creating a Windows Azure Service Definition
Unfortunately there isn’t a magical tool that will create a starter point for our Service Definition file, this is mostly due to the fact that Microsoft doesn’t know what to provide as a default. Windows Azure is all about Developer freedom, you create your application and let Microsoft worry about the infrastructure that it’s running on.
Luckily, Microsoft has documented the Service Definition (.csdef) file on MSDN, so we can use this documentation to guide us through the creation of our Service Definition. Let’s create a file called ‘ServiceDefinition.csdef’ outside of our Deployment folder. We’ll add the following content to the file, and I'll explain a few of the key elements below.
Defining a Windows Azure Service
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="PHPonAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="Deployment" vmsize="ExtraSmall" enableNativeCodeExecution="true">
<Startup>
<Task commandLine="install-php.cmd" executionContext="elevated" taskType="background" />
</Startup>
<Endpoints>
<InputEndpoint name="defaultHttpEndpoint" protocol="http" port="80"/>
</Endpoints>
<Imports>
<Import moduleName="RemoteAccess"/>
<Import moduleName="RemoteForwarder"/>
</Imports>
<Sites>
<Site name="PHPApp" physicalDirectory=".\Deployment\Websites\MyPHPApp">
<Bindings>
<Binding name="HttpEndpoint" endpointName="defaultHttpEndpoint" />
</Bindings>
</Site>
</Sites>
</WebRole>
</ServiceDefinition>
We will be using a Windows Azure WebRole to Host our application [remember WebRoles are IIS enabled], you’ll notice that our first element within our Service Definition is WebRole. Two Important pieces of the WebRole Element are the vmsize and enableNativeCodeExecution attributes. The VMSize Attribute hands off the VM Sizing requirements to the Fabric Controller so it can allocate our new WebRole. For those of you familiar with the .NET Stack the enabledNativeCodeExecution attribute will allow for FullTrust if set to true, or MediumTrust if set to false [For those of you that aren’t familiar, Here’s a Description of the Trust Levels in ASP.NET]. The PHP Modules for IIS need elevated privileges to run so we will need to set enableNativeCodeExecution to true.
In Part one of this series we created a command-line script that would initialize a PHP installation using WebPI. You’ll notice under the Startup Element, we’ve added our script to a list of Task Elements which defines the startup Tasks that are to be run on the Role. These scripts will run in the order stated with either limited [Standard User Access] or elevated [Administrator Access] permissions. The taskType determines how the Tasks are executed, there are three options simple, background and foreground. Our script will run in the background, this will allow us to RDP into our instance and check the Logs to ensure everything installed properly to test our deployment.
In the Service Definition above we’ve added some additional folders to our deployment, this is where we will be placing our website [in our case, we’re simply going to add an index.php file]. Within the Deployment Folder, add a new folder called Websites, within the new Websites folder, create a folder called MyPHPApp [or whatever you would like it named, be sure to modify the physicalDirectory attribute with the folder name].


Now that our directories have been added, create a new file named index.php within the MyPHPApp folder and add the lines of code below.
Creating a Windows Azure Service Configuration
Now that we have a Service Definition to define the hard-requirements of our Service, we need to create a Service Configuration file to define the soft-requirements of our Service.
Microsoft has provided a way of creating a Service Configuration from our Service Definition to ensure we don’t miss any required elements.
If you intend to work with Windows Azure Tools on a regular basis, I would suggest adding the Path to the tools to your System Path, you can do this by executing the following script in a console window.
path=%path%;%ProgramFiles%\Windows Azure SDK\v1.3\bin;
We’re going to be using the CSPack tool to create our Service Configuration file. To Generate the Service Configuration we’ll need to open a console window and navigate to our project folder. Then we’ll execute the following command to create our Service Configuration (.cscfg) file.
cspack ServiceDefinition.csdef /generateConfigurationFile:ServiceConfiguration.cscfg
After you run this command take a look at your project folder, it should look relatively close to this:

You’ll notice that executing CSPack has generated two files. First, It has generated our Service Configuration file, which is what we’re interested in. However, the tool has also gone and compiled our project into a Cloud Service Package (.cspkg) file, which is ready for deployment to Windows Azure [we’ll get back to the Cloud Service Package in the next post in this series]. Let’s take a look at the Configuration file.
<?xml version="1.0"?>
<ServiceConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serviceName="PHPonAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="Deployment">
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="" />
</ConfigurationSettings>
<Instances count="1" />
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="0000000000000000000000000000000000000000" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
Where did all of this come from? Let’s look at a simple table, that matches up how these settings relate to our Service Definition.
|
Service Definition Snippet
|
Service Configuration Snippet
|
| <ServiceDefinition name=”PHPonAzure”/> |
<ServiceConfiguration serviceName=”PHPonAzure”/> |
| <WebRole name=”Deployment”/> |
<Role name=”Deployment”/> |
| <Import moduleName=”RemoteForwarder”/> |
<Setting name=”RemoteForwarder.Enabled”/> |
| <Import moduleName=”RemoteAccess”/> |
<Setting name=”RemoteAccess.Enabled”/>
<Setting name=”RemoteAccess.AccountUsername”/>
<Setting name=”RemoteAccess.EncryptedPassword”/>
<Setting name=”RemoteAccess.AccountExpiration”/>
<Certificate name=”RemoteAccess.PasswordEncryption”/> |
For more information on the RemoteAccess and RemoteForwarder check out the series that I did on RDP in a Windows Azure Instance. These posts will also take you through the instructions on how to provide proper values for the RemoteAccess and RemoteForwarder Elements that were Generated by the Import statements in the ServiceDefinition.
- Upload a Certification to an Azure Hosted Service
- Setting up RDP to a Windows Azure Instance: Part 1
- Setting up RDP to a Windows Azure Instance: Part 2
- Connecting to a Windows Azure Instance via RDP
There are two additional attributes in which I would recommend adding to the ServiceConfiguration Element, osFamily and osVersion.
osFamily="2" osVersion="*"
These attributes will change the underlying Operating System Image that Windows Azure runs to Windows Server 2008 R2 and sets your Role to automatically update to the new image when available.
You can control the number of instances of your Roles are deployed by changing the value of the count attribute in the Instances Element. For now we’ll leave this value at 1, but keep in mind that Microsoft’s SLA requires 2 instances of your role to be running in order to guarantee 99.95% uptime.
Great Resources
Conclusion
In this entry we created both a Service Definition and a Service Configuration. Service Definitions provide information to the Fabric Controller to create non-changeable configurations to a Windows Azure Role. The Service Configuration file will provide additional information to the Fabric Controller to manage aspects of the environment that may change over time. In the next post we will be reviewing the Cloud Service Package and Deploying our Cloud Service into the Windows Azure Environment.
Happy Clouding!
This article also appears on SyntaxC4's Blog.
Remembering back to when I was in the Audience in the Community, the one thing I always wanted to find out about was Best Practices for the Particular Technology I was listening about. I’m sure a number of people feel the same way.
Best Practices are hard to introduce in a talk as you’re typically only speaking to 10% (if that) of your audience and leaving the other 90% scratching their heads. For this reason, I am providing this blog post as a resource to find allow people interested in Best Practices to proactively seek them out with a little bit of Guidance.
Getting in the Know
Let’s face it, you may want to know the Best Practices from the beginning as you think you’re doing yourself a favour by knowing how to be a smooth operator. STOP, Let’s take a moment to step back and thing about this.
Just because something has been outlined as a best practice doesn’t guarentee that it is for your particular situation. Part of Identifying a Best Practice is knowing your options for a particular situation. Once you know you have the right fit for your particular situation then you can extend your implementation to leverage a Best Practice to Guarentee that you’ve solidified your feature in it’s Best Possible Functioning Implementation.
My First Tip for seeking out best practices is to Know your Platform & Your Options.
There are a number of resources for getting to know Windows Azure on my blog [which I’ve recently installed Microsoft Translator to provide great content for all to read] and the Windows Azure Team Blog.
Further Research is Necessary
As good as the content is that you read online, you will want to turn to a number of printed [or electronic] books. Here are a few books that I would suggestion.
Manning Books – Azure In Action

This book is not about Best Practices. However, it provides the best explanation of the Windows Azure Internals to date. The first few chapters provide insight into the Fabric Controller and the Windows Azure Fabric.
I would consider this an initial “Deep Dive” Starter read to get into Microsoft’s Cloud Computing initiative and an understanding of Windows Azure’s offerings in the Platform as a Service (PaaS) Cloud Space.
Microsoft Patterns & Practices

My most recent read was Moving Applications to the Cloud by the Microsoft Pattern and Practices Team. This book was very insightful as to some of the Practices that Microsoft has been implementing while moving into the cloud, obviously obfuscated through a hypothetical company Adatum and their Expenses Tracking System aExpense.
This book got me thinking about a number of great architecture concepts and some great value add code that can be re-used over a number of Projects.

I enjoyed the previous book so much that I will be picking up the other guidance book from Microsoft, Developing Applications for the Cloud.
I’m going out on a limb to say that based on the previous book, I’m betting that this book will be rather insightful, hopefully providing more guidance on Architecting Applications for Windows Azure.
The Cloud Developer Tool Belt Reference Guide
This next resource might not be something you will read end to end. I would say that this is definitely an item you should be referring to when designing your Cloud Architecture.
AzureScope: Benchmarking and Guidance for Windows Azure is an all encompassing guide for Best Practices, Benchmarks, Code Samples next to which my Essential Guide for Getting Started with Windows Azure post look like one of those rings you pick up at the cash register of your local dollar store.

Conclusion
Hopefully this post will help those in my audiences that I am unable to reach out to at this point with that Best Practice Deep Dive. I have no doubt that Cloud Computing is the future of Application Deployment and Hosting. I also believe that Microsoft is putting forth a very strong offering with Windows Azure. Regardless your technology, the Best Practices provided in this document will provide you with some thought provoking reading material which after all is most likely one of the main contributing factors in choosing Software Development as a Career.
Happy Clouding!
Considering this blog post is about an open source language (PHP), I’m intentionally avoiding my trusty development tool Visual Studio. Even without using Visual Studio it will be necessary to download the Windows Azure Tools & SDK 1.3, this will provide us with some necessary command-line tools. That’s right, Windows Azure is Console Ready!
Context is Everything
Over the next three blog posts, I am going to be describing how to Install PHP on Windows Azure.
With the release of the 1.3 release of the Windows Azure SDK, Microsoft has enabled Full IIS (Internet Information Services) support in Windows Azure [this provides support for IIS Modules] and Start-up Scripts [which allow you to run command-line or powershell scripts on your deployment while the role is starting].
We will be leveraging start-up scripts to execute the [new] WebPI Command-line tool to install and configure PHP in IIS within a Windows Azure Web Role.
We need a few things to Help us along the Way
- Web Platform Installer [WebPI] Command-line Tool [Any CPU]
- Windows Azure Tools & SDK 1.3
- Your Favourite Text Editor [I like Notepad++]
Creating your Start-up Scripts
Before we can even write our first start-up script there is one thing we need to get out of the way first and that’s where we create them. To understand what we’re doing lets do a quick break down on how deployments work in Windows Azure.
Breaking down a Windows Azure Deployment
Windows Azure requires only two files when deploying an application to the Cloud.
First, is a Cloud Service Package file which is essentially a Zip file which contains a number of encrypted files. Amongst these encrypted files are:
- A Cloud Service Definition file which defines the fixed resources for our Windows Azure Compute Instance. The Service Definition is responsible for setting up Web Roles, Worker Roles, Virtual Machine Roles and Network Traffic Rules. These settings are then relayed to the Fabric Controller which selects the appropriate resources for your Compute Instance from the Fabric and begins provisioning your Deployment.
- Your Application, which can consist of many Roles. Considering we’re using the Platform as a Service Model that Windows Azure offers, there are two main types of Roles: Web Roles and Worker Roles. A Web Role is like a typical Web or Application Server which runs IIS and Serves up Web Content. A Worker Role is a continuously running process which basically mimics a Windows Service.
Second, is the Cloud Service Configuration file which builds on top of what the Service Definition file provides to the Windows Azure Fabric Controller, only these values can be changed without the need to redeploy the Service Package. The Service Configuration is where you control the number of Instances your application is distributed across, as well as Windows Azure Storage Service Connection Strings and other values which may need to get changed over an Applications Lifespan.
That’s Great, but why did you tell me this?
Windows Azure is using the Convention over Configuration approach when it comes to start-up script location. You will be configuring where your application is actually located on your physical machine, but the Azure Tools are going to be looking for your scripts in ‘AppRoot/bin’. The AppRoot is determined by the name of your Role within the Service Definition file.
For now, lets stick with a very simple directory structure and we’ll talk about the Service Definition in the next post. In a directory that you’ve created for your deployment create a ‘Deployment’ directory and within that create a bin folder. We will be adding our start-up scripts to the bin folder.

Show me The Code Already!
Fire up Notepad++ we’re going to create our start-up scripts to enable PHP within IIS in Windows Azure.
The first script that we need to create will enable Windows Update on the Windows Azure Web Role Image. The WebPI tool uses the Windows Update Process to install the Items that have been downloaded. Create a file, ‘enable-windows-update.cmd’ and paste the following script.
Script for enabling Windows Update
@echo off
IF "%PROCESSOR_ARCHITECTURE%" == "x86" GOTO End
IF "%PROCESSOR_ARCHITECTURE%" == "AMD64" GOTO x64
:x64
sc config wuauserv start= demand
GOTO End
:End
All Windows Azure Instances run on 64bit Processors, so you can possibly get rid of the Conditional logic.
Our next script is going to leverage the WebPI Commandline tool which you would have downloaded from the resource list above. This download is also required as part of the Cloud Service Package that we will be creating in a future post. Within the Deployment directory, create a folder called ‘Assets’ and another folder within 'Assets’ called ‘WebPICmdLine’. Copy the WebPI binaries into the newly created WebPICmdLine folder.
Note: The WebPI tool is very powerful tool and can do much more than just install PHP. You may want to read the documentation found on the IIS Blogs and on MSDN.
Create a new file, 'install-php.cmd' and paste the following script.
Script for installing PHP with WebPI
@echo off
ECHO "Starting PHP Installation" >> log.txt
"..\Assets\WebPICmdLine\WebPICmdLine.exe" /Products:PHP52 /AcceptEula /log:phplog.txt
ECHO "Completed PHP Installation" >> log.txt
REM This isn't necessary, but may be handy if you want to leverage all of Azure.
install-php-azure
The last line of that Script is a call to another script that needs to be run after PHP is actually installed. This isn’t a necessary step, however the ‘install-php-azure’ script [provided below] will place the ‘php_azure.dll’ in the php/ext folder and add the extension within the php.ini file. Adding the dll from the Open Source Project Windows Azure SDK for PHP available on CodePlex gives you the ability to leverage Blobs, Tables, Queues and other Azure API features.
You will need to add the php_azure.dll file that you download from CodePlex to the Assets directory [for consistency create a directory called ‘Windows Azure SDK for PHP’]. Create a file, ‘install-php-azure.cmd’ and paste the following code.
Script for Installing Windows Azure SDK for PHP
@echo off
xcopy "..\Assets\Windows Azure SDK for PHP\php_azure.dll" "%PROGRAMFILES(X86)%\PHP\v5.2\ext"
echo extension=php_azure.dll >> "%PROGRAMFILES(X86)%\PHP\v5.2\php.ini"
After you have completed creating these three files your folder structure should look like this:

Until Next Time…
We have completed creating the scripts required to install PHP on Windows Azure. In my next blog post in this series I will explain how to create the Cloud Service Definition and Cloud Service Configuration files. We’ll start to get a better understanding as to how our Deployment fits together in the Windows Azure Platform. In the Third Part of this series we will package the Deployment using the command-line tools for Windows Azure and finally deploy our application to the cloud.
This article also appears on SyntaxC4's Blog.
Note: This is by no means anything new, but I’ve been referring a lot of people to it lately so I thought that I should share it with my readership on my blog. The Following video was recorded by Scott Hanselman at PDC09.
Have you ever wondered what a Windows Azure Data Container looked like? Perhaps you’ve been curious how Microsoft keeps their services cool in these vast shipping containers we all know an love as the Windows Azure Cloud.
Patrick Yantz a Cloud Architect from Data Center Services at Microsoft gives follow Program Manager Scott Hanselman a tour of a Proof of Concept (PoC) Data Center.
A Tour of a Cloud
The video is about 16 minutes long and provides a lot of information about the Technologies Microsoft Leveraged to create their Data Centers.
Building a Cloud
Microsoft has released another video that shows how the Data Containers are built. Just incase you’re curious, here is the video that shows the production of a Windows Azure G4 Data Container.
The video is about 3 minutes in length.
Happy Clouding!
This article also appears on SyntaxC4's Blog.
One of the hardest things we face as developers is Troubleshooting and Debugging code in different environments and scenarios, this continues to hold true in the Cloud. This Blog post will outline some of the resources available to developers that are trying to troubleshoot Windows Azure.

Troubleshooting the Environment in Windows Azure
Troubleshooting Windows Azure Operating System Issues
Even though the Cloud attempts to limit diversity amongst it’s hardware, the Operating System is something that will always need to be able to adapt new features or emerging security threats.
One thing that Microsoft has done particularly well is keeping Operating System upgrades very Abstract in Windows Azure by releasing a new Virtual Machine (VM) Image (OS Guest) with every set of new upgrades. The VM images are controlled in the Cloud Service Configuration (cscfg) file by setting the osFamily and osVersion attributes.
OS Guest Resources
VM Role Resources
Troubleshooting Windows Azure Deployment
Deployment is the stage of development in which you have the least amount of control. A number of Debugging paradigms are not available unless the Role Initializes and is created successfully. Once the Role is created, you will be able to debug using Remote Desktop Access to Windows Azure (if configured), or Download Intellitrace Diagnostics Information (if enabled).
With the introduction of Start-Up Tasks, many new scenarios that may involve debugging have been introduced. Be sure to test your startup scripts using RDP before trying to deploy your application with the Tasks configured in the Cloud Service Definition (csdef) file.
Deployment Resources
Service Management Resources
Windows Azure Diagnostics Resources
Troubleshooting Windows Azure Platform
This includes both the Tools & SDK as well as support for .NET Libraries & Technologies.
Windows Azure Platform Resources

Troubleshooting SQL Azure
SQL Azure is a Relational Database System in the Cloud. Microsoft’s Cloud approach to the cloud does not limit support for Popular Programming Languages and therefore was a need for a Management Component for SQL Azure to allow those who are not using the Microsoft Stack a way to manage their SQL Azure database without the need to install SQL Server Management Studio (SSMS).
SQL Azure Database Troubleshooting
When Microsoft started Venturing down the road of Creating SQL Azure they had a number of security concerns to address exposing a full features SQL Server instance in the Cloud. With this in mind, there were a number of features that were pulled out of SQL Azure from your typical install of SQL Server 2008.
Along the same lines of feature support for SQL Azure, there were a number of commands that needed to be cut from T-SQL in the Cloud.
SQL Azure Resources
Transact-SQL (T-SQL) Resources
SQL Azure Manager Troubleshooting
Formerly Project Houston, the Database Manager for SQL Azure is a new service offering (Released at PDC 2010). An extremely compelling offering being able to manage a database from any computer that has internet connectivity, with one limitation, a dependency on the Silverlight Browser Plugin (which in my opinion *everyone* should have).
Database Manager for SQL Azure Resources

Troubleshooting Windows Azure Security
Security is one of the Major concerns in the Cloud, Hopefully you aren’t using these to troubleshoot someone breaking into your application on Windows Azure, but actually reading them while you’re preparing your architecture plans for your system.
Windows Azure Security Resources
This article also appears on SyntaxC4's Blog.
This following blog post was co-authored by John Bristowe and Cory Fowler.

Important! Check out the Windows Azure Introductory Special. It is the easiest way to get started with Windows Azure. To make it even easier, Barry Gervin and Cory Fowler have created some step by step videos on how to register for Windows Azure using the Introductory Special. If you’re a [Premium, Ultimate, or BizSpark] MSDN Subscriber, you are eligible to participate in a Windows Azure Benefits which includes free consumption of Windows Azure Services.
Essential Downloads
Folks in the Know
Events
Blogs and Websites
Essential Reading
Books
-
Applied Architecture Patterns on the Microsoft Platform by Richard Seroter, Ewan Fairweather, Rama Ramani, Mike Sexton, and Stephen W. Thomas (Packt)
Azure in Action by Chris Hay and Brian H. Prince (Manning)
Cloud Computing with the Windows Azure Platform by Roger Jennings (Wrox)
Pro SQL Azure by Scott Klein and Herve Roggero (Apress)
Windows Azure Platform by Tejaswi Redkar (Apress)
Windows Azure Projects by Jim Zimmerman, Scott Densmore, David Makogon, Maarten Balliauw, and Scott Ma (Apress)
Windows Azure Platform: Articles from the Trenches Volume 1 by Eric Nelson, Marcus Tillett, Ricahrd Prodger, Saksham Gautam, Rob Blackwell, Julien Hannsens, Simon Munro, Steve Towler, Sarang Kulkarni, Grace Mollison, Jason Nappi, Josh Tuchoiski, David Gristwood, Neil Mackenzie, Steven Nagy
Screencasts/Videos/Webcasts
Essential Listening
Projects, Third Party Tools and Other Downloads
Essential Code/Scripts/Virtual Labs
This article also appears on Canadian Developer Connections.
This post is a conclusion to a series of blog entries on how to RPD into a Windows Azure instance. If you haven’t already done so, you may want to read the previous posts:
This post will provide two pieces of information: first, now that your Windows Azure Platform Portal has been configured for RPD, I will show you how to initialize the RDP Connection to a Windows Azure Instance. Second, I’ll step back and explain how to Setup the Cloud Service Configuration manually (which is typically automated by Visual Studio).
Connecting to Windows Azure via RDP
At this point you should have already uploaded a Certificate to the Hosted Service, checked the Enable checkbox in the Remote Access section of the Portal Ribbon and configured a Username and Password for accessing the particular Hosted Service.
In the Hosted Service Configuration page, select the Instance you would like to connect to.

This will enable the Connect button within the Remote Access section of the Portal Ribbon. Click on the Connect button to initialize a download of the RPD (.rpd) file to connect to that particular instance.

You can obviously choose open, however this is a good opportunity to save the RDP connection to an instance just for that odd chance you can’t access the Windows Azure Platform Portal to download it again. I would suggest saving at least one RDP file in a save location for this very reason.

You may need to accept a Security warning because the RDP file is Unsigned.

Then supply your username and password which was set up in the previous set of posts.


Once the connection has been initialized there is one last security warning to dismiss before the desktop of your Windows Azure Instance appears.

Welcome to your Windows Azure Instance in the Cloud!

Manually Configuring RDP Access to Windows Azure
In order to manually configure RDP access to a Windows Azure Instance in the csconfig file there are a few things that need to be done. There is a well written outline on MSDN in a post entitled “Setting up a Remote Desktop Connection for a Role”.
During Step 2 of the process outlined on MSDN, Encrypting the Password with Powershell, there is the need to provide a thumbprint for a Self-Signed Certificate. What isn’t mentioned within the article is that it is necessary to Capitalize the Letters and Remove the Spaces in the thumbprint in order for the Powershell script to work.
Happy Clouding!
This post also appears on SyntaxC4's Blog.
In our last set of Videos [Post #AzureFest Follow-up Videos] Barry and I talked about how to Register for a Windows Azure Account, Setting up a Hosted Service, Deploying your first Azure Application, and tearing down the Application.
In this set of videos Barry and I walk-thru setting up a SQL Azure Database using the Windows Azure Platform Portal, as well as Generating Script files for the existing NerdDinner Application for Deployment into the Cloud.
Setting Up a SQL in the Cloud using SQL Azure
As explained at AzureFest, there are very few steps required to set up a Database on SQL Azure. The main thing to watch for in this video is the Firewall settings, this is important to keeping your data secure in the cloud. If you set up Firewall rules for Cafe’s or Restaurants, be sure to remove the IP Address Range from the Firewall before you exit the establishment.
Setting up a SQL Azure Instance for Cloud Based NerdDinner Deployment
Generating Scripts against On-Premise Database to Deploy to SQL Azure
In this Video, Barry and I explain how to script the existing on premise databases from the NerdDinner Application and run those scripts against our newly created SQL Azure Database. We also venture into the new SQL Azure Database Manager [Built on Windows Azure with Silverlight].
Scripting Database Tables and Running Script against SQL Azure
Next Steps…
Look for some additional content coming in the New Year! Barry and I will be covering Setting up your environment, and deploying the full NerdDinner Application to the Cloud!
This post also appears on SyntaxC4's Blog.
In my last post, Setting up RDP to a Windows Azure Instance: Part 1, I explained how to setup Remote Desktop into the Cloud using Visual Studio 2010.
However, the cloud isn’t for Developers alone, we have to think of our IT Pro counterparts. This post will explain how to setup and configure RDP access to the Cloud without using Developer Tools.
Creating a Self-Signed Certificate with IIS7(.5)
1. Open IIS, Double-Click on Server Certificates.

2. In the Actions menu on the right, Select “Create Self-Signed Certificate…”.

3. Specify a Friendly Name for the Certificate.

4. Ensure the new Certificate has been created.

Using the Windows Azure Service Management API
So I said I was going to use the Service Management API and I am, however I am going to cheat a little bit by using the Windows Azure Service Management CmdLets [which is a convenient PowerShell Snap-in created by Ryan Dunn (@dunnry)].
Before we can interact with the Service Management API we must upload a Management Certificate [which is similar to he process outlined in my previous post on Exporting and Uploading a Certificate to Windows Azure]. The Management Certificates are uploaded from within the Windows Azure Platform Portal as seen in this picture to the right.
Management Certificates are used by Visual Studio to interact with the Windows Azure Platform. The Management Certificate paired with the Subscription ID are used to Authenticate Access to the Windows Azure APIs.
Now that we’ve covered the Management Certificates, lets fire up the Windows PowerShell ISE.
Using the Windows Azure Service Management CmdLets
If you haven’t already done so download the Windows Azure Service Management CmdLets.
First you will have to tell PowerShell you would like to use the snap-in, use the following snippet of code to add the Azure Management Tools Snap-in.
Add-PSSnapin AzureManagementToolsSnapIn
If you’d like to list all the Commands that are included in the Windows Azure Management Snap-in simply execute this line of code:
Get-Command -PSSnapIn AzureManagementToolsSnapIn
We’re going to be using the Add-Certificate command to add a Certificate to our Hosted Service. First lets take a look at some of the examples of how to use this command by executing:
Get-Help Add-Certificate
As you can see there are a few options for running the Add-Certificate Command, I’ve chosen this format:
Add-Certificate -ServiceName RDP2Azure
-CertificateToDeploy (gi <path-to-cert>\azurefest-RDP.cer)
-Subscription ID ********-****-****-****-************
-Certificate (gi cert:\CurrentUser\My\<thumbprint>)
There are two “Certificate” Arguments which can be confusing especially when they accept different values. CertificateToDeploy is the newly created Certificate which will be used to encrypt the password for our RDP Connection, this argument accepts a file as a parameter. The Certificate argument is the Management Certificate that is being leveraged to Authenticate the transaction. When you run the Script the result should look like this:

You’ll also notice that the Certificate has been uploaded to the Windows Azure Platform Portal.

Configuring RDP in the Windows Azure Platform Portal
Now that we’ve created the Certificate needed to encrypt the RDP password, and we’ve used the Azure Service Management API to upload the Certificate to our hosted Service. Now it’s time to configure our RDP Connection in the Windows Azure Platform Portal.
To Configure our RDP Access, Select the Role you wish to configure the RDP access for. Then in the Ribbon check off the Enable checkbox, then click on the Configure Button in the Remote Access Group.

Set your username and password for the RDP Connection. Select the Certificate you wish to use to encrypt the password, then select an expiration date for the connection.
Once you’ve finished these steps you will be able to select an instance and Connect to the Cloud.
**Note: I’ll be creating one last entry to review the process of opening up the RDP File to gain access to an Instance running on Windows Azure.
Conclusion
This post was considered the IT Pro explanation for how to grant access to RDP in the Cloud. These skills are transferrable to Development as well if you don’t have Visual Studio. I will create one final post which explains how to manually create the XML nodes that Visual Studio creates in the Cloud Service Configuration file auto-magically using it’s UI. This manual creation is intended for Open Source Developers or Developers that like to understand how the underlying pieces of the Visual Studio Tools Operate.
This post also appears on SyntaxC4's Blog.
In my previous post, Export & Upload a Certificate to an Azure Hosted Service, I outlined some of the common tasks which are necessary to RDP into a Windows Azure Hosted Instance. In this post I will outline how to use the tools in Visual Studio to setup the RDP Configuration values.
Part 2 of this Series will outline how to Configure the RDP Manually, using IIS, Powershell and the Service Management API. One final post will outline how to get the RPD Connection launched.
Using Visual Studio to RDP to an Azure Instance
If you’re a Developer, this is most likely the simplest process for you. The following steps explain the process of setting up RDP to the Cloud, so a number of Development Processes, including building out your Website are *not* covered.
Visual Studio 2010 Cloud Service Project
1. Welcome to the Start Screen.

2. Create a New Cloud Service Project.

3. Select the Required Projects for the Solution.

Publish the Application to Windows Azure
1. [Time Lapsed: Build Application] Right-Click on Cloud Service Project and select Publish.

2. Choose your Hosted Service and Storage Account to Deploy to.

3. Configure Remote Desktop connections.

4. Create a Certification (this is used to encrypt the credentials).

5. Create a Username and Password for the RPD Connection.

6. Export and Upload the Certificate to the Hosted Service.

7. Press OK on both the Remote Desktop Setup and Publish Dialog boxes. This will begin the Publish Process.

Next Steps
This concludes the configuration of RDP into a Windows Azure Instance using Visual Studio 2010. The next step would be to connect to the Windows Azure instance. I will be posting another entry to cover the steps to connect, however it will be after I complete my next entry on how to Manually Configure the RDP Connection.
This post also appears on SyntaxC4's Blog.
Last night I started doing some research into the new features of the Windows Azure SDK 1.3 for a future blog series which I’ve been thinking about lately. The first step was to figure out what was installed on the default Windows Azure image, in order to determine what would need to be installed for my Proof of Concept.
There are two ways to set up the RDP connection into an Azure instance: a developer centric approach, which is configured in Visual Studio, and an IT centric approach which is configured through the [new] Windows Azure Platform Portal. I had thought it might be cool if this functionality was available using the Service Management API, however this is not publicly exposed [which probably is a good thing].
To minimize content repetition I decided to split the export and upload process to this blog post.
Exporting a Certificate
1. Open the Certificate (From Visual Studio Dialog, IIS or Certificate Snap-in in MMC)

2. Navigate to the Details Tab. Click on Copy to File…

3. Start the Export Process.

4. Select “Yes, export the private key”.

5. Click Next.

6. Provide a password to protect the private key.

7. Browse to a path to save the .pfx file.

8. Save the file.

9. Finish the Wizard.


Setting up a Windows Azure Hosted Service
If you’d like to see a more detailed explanation of this, I released some videos with Barry Gervin in my last entry, “Post #AzureFest Follow-up Videos”.
1. Create New Hosted Service.

2. Fill out the Creation Form.

Setting up a Windows Azure Storage Service
The Visual Studio Tools will not allow you to deploy a project without setting up a Storage Service.
1. Create a New Storage Service.

2. Fill out the Creation Form.

Upload the Certificate
1. Select the Certificates folder under the Hosted Service to RDP into. Click Add Certificate.

2. Browse to the Certificate (saved in last section).

3. Enter the Password for the Certificate.

4. Ensure the Certificate is Uploaded.

Moving Forward
This entry overviewed some of the common setup steps between Setting up RDP using Visual Studio, and Manual Configuration. In the Manual Configuration post I will overview how to use the Service Management API to install the Certificate to the server (instead of the Portal as described above).
Happy Clouding!
This post also appears on SyntaxC4's Blog.
Recently, I was working on a project that required a site migration from a Shared Hosting server to Windows Azure. This application has been up and running for sometime and had acquired quite a substantially sized database.
During the course of the project I ran across a few road blocks which I wasn’t expecting, due to the experience gained in my previous blog entries: Migrate a database using the SQL Azure Data Sync Tool and Scripting a database for SQL Azure (Issues explained in previous link resolved with launch of SQL Server 2008 R2). Hopefully the following tricks will help you along your data migration.
Using Import/Export in SSMS to Migrate to SQL Azure
In addition to the SQL Azure Data Sync Tool, it is possible to use the existing Import/Export Wizard in SQL Server Management Studio to migrate data to SQL Azure. There are a number of things to keep in mind while using the Import/Export Tool:
SQL Server Native Client to .NET Data Provider for SqlServer
SQL Azure doesn’t fall under the typical SQL Server Native Client 10.0 Product SKU, this means that you’ll have to use the .NET Data Provider to migrate your data. The configuration screen for the provider is very intuitive, but there are two key settings that should be changed from their default values, Asynchronous Processing (set to true) and Connection Timeout (increase to 1500).

Without changing the Timeout value the data migration would error out after creating the fist few sets of rows. Making this an Asynchronous process was beneficial when exporting multiple tables at a time.
Work-around for SSIS Type: (Type unknown …) Error
There is a chance when you go to run the migration that you will encounter an error as described in Wayne Berry’s [@WayneBerry] blog post entitled “SSIS Error to SQL Azure with varbinary(max)” on the SQL Azure Blog.
As Wayne explains in his post, there are a number of XML files which contain data mapping information used by the Import/Export Wizard in order to map the data from the source database to the proper data type in the destination database.
Database Seeded Identity Insert Issue
I’m not sure why this happened, but when using the Import/Export even with Identity Insert on, the ID [Identity] Column was not Inserting the correct values. To get around this I used the ROW_NUMBER to generate new Identities and rebuilt the foreign key tables.
There is a lot of chatter on the Forums and other blog posts that say that BCP with the –E switch is the most effective way to do exact copying (with Identity Columns).
For more information:
Cost Effective Approach
A good thing to keep in mind while preparing your database for migration is that transactions as well as data transfer costs are applied to Queries to (and from) SQL Azure. With this in mind it would be best to set up a scenario where you would test your data migration to ensure the data migration would be performed in the least number of attempts as possible.
Happy Clouding!
This post also appears on SyntaxC4's Blog