Umbraco on Azure Series: Deploying to Azure with Accelerator
JANUARY 11 2011This is the second post in the series about deploying Umbraco to Windows Azure. In the previous post we looked at deploying a clean Umbraco database to SQL Azure, so this post assumes that you have a database running on SQL Azure.
The focus of this post is to get your local Umbraco solution deployed to a Hosted Service on Windows Azure. Well, you actually need two services to deploy Umbraco because the Hosted Service is only half of running Umbraco on Azure, so deployed to a Hosted Service and Storage. During the deployment you will be creating a virtual harddrive, which will be deployed to Storage. So before getting started please make sure you have access to both Hosted Service and Storage.
In this post the Azure Accelerator project will come into play, and is listed in the prerequisites below. The cool thing about Accelerator is that it "just" needs to be configured and then it'll build a virtual harddrive (VHD) containing your Umbraco solution and upload it to storage for you. Aside from that you will also be able to publish the two packages (Configuration cscfg-file and Package cspkg-file) needed to deploy the worker role, which is the Azure VM instance that keeps your site running. The binding between the hosted Azure instance and VHD in storage is done by configuring (step 3) and running Accelerator. The Azure VM is the equivalent of a website instance in your IIS, but since this is a cloud service the instance will live and die in the cloud. This means that if you stop the instance it will die, if the instance crashes it will die (for a production site you would have at least two instances running, so your website doesn't die if one instance crashes). Because of this you need your Umbraco solution persisted to storage, which is where the Azure Storage and VHD comes in. So basically you will have a lot less to worry about when using the Accelerator project.
Prerequisites: Umbraco database running on SQL Azure from previous post (or an embedded database if you don't want to use SQL Azure). Local Umbraco (4.5.2 .NET 3.5) solution using the database on SQL Azure. Keys for Azure Storage (more info will follow). The two guides on The Azure Accelerators Project from codeplex. Source Code for Azure Accelerator from codeplex. Visual Studio 2010 with Cloud Sevice v.1.2 installed. - Windows Azure SDK version 1.2 (included in Cloud Service installation) - look for June 2010 release (version 1.2) at the bottom of the page. - Windows Azure AppFabric SDK version 1.0. - Note that the version is very important as the Azure Accelerator will not work with newer versions of the SDK. At least for now, as I'm still to figure out if there is a conflict when using newer versions of the SDK. Using version 1.3 of the SDK has proven troublesome for Warren Buckley. So to save yourself a headache go with version 1.2 of the SDK untill it has been investigated further.
Make sure you have installed the SDKs from the list above before going further.
1.) First off I will show you how to setup Storage on Windows Azure, as you will need access keys for storage in order to deploy the VHD to Azure Storage. Go to the WindowsAzurePlatform portal and login. If you are prompted to choose which version of the portal you want to use then choose the new one. Its built in Silverlight and works quite nice. From the left column click "Hosted Serivces, Storage Accounts & CDN" (see screenshot below).
Now your available services will be listed, so click "Storage Accounts" from the left column and then "New Storage Account" from the top menu.
A new dialog pops up where you have to choose your Storage Account subscription, a name that will make up the url and a region - select a region that is close to you. See screenshot below.
When you have clicked the Create button you will see the storage account appear in the main window. Click and you will get a new right column with properties. Copy the Primary access key and your Storage Account name as they are needed in the configuration of the Accelerator project.
Now you have succesfully created a storage account that you can use to deploy your VHD with Umbraco solution to. But first you need to configure the Accelerator project and build it, so you can have it create and upload the VHD for you.
2.) Unzip the Azure Accelerator solution and open it with Visual Studio 2010. Unbind the solution from (codeplex) source control and make the files writeable, as you need to update a couple of files. First thing I recommend you do is to look through the references for the 3 projects, just to make sure there are no missing references or version conflicts. Finally build the solution to verify it also builds.
3.) This step is probably the most complicated one, because there are alot of settings to go through to configure the solution. Before going any further I recommend that you read the two guides from the Azure Accelerator project page if you haven't already done so.
Locate the "AcceleratorService" project in the solution and right click Properties on the AcceleratorWorkerRole to edit the various settings. See screenshot below.
I'm not what the best approach for going through these settings are, so I have listed them all with their default value and written what you should change the value to - if the value needs to be changed.
Configuration: Full trust - leave it set to full trust. Instances is by default set to one instance with Medium VM size. You can leave this as is, but it is recommended to deploy production sites with minimum two instances. For this guide you don't need more then one. Note: Remember that two instances implies higher costs. Also note that a Medium VM isn't super fast, so consider setting it to Large or Extra Large.
Settings: AcceleratorApplication - Default: Umbraco,3.x Change to Umbraco,4.0
AcceleratorConnectionString - Default: UseDevelopmentStorage=true Change this by clicking ... and enter your storage credentials in the dialog. See screenshow below:
When changed the connectionstring should look something like this: DefaultEndpointsProtocol=http;AccountName=YourStorageAccountName;AccountKey=YourStoragePrimaryAccessKey
LocalSitePath - Default: C:\inetpub\wwwroot This is the path to the folder containing the Umbaco solution. If you have installed your Umbraco website to the default location you probably don't need to change it, but make sure the path is correct and change if necessary.
AcceleratorConfigBlobUri - Default: wa-accelerator-config/umbraco.config This is the default location for the umbraco.config, which is being used by Accelerator so leave this setting as is.
AcceleratorContainerSyncUri - Default: wa-accelerator-apps/inetpub Also a default setting that you don't need to change.
AcceleratorMachineKey - Default: <machineKey validationKey="A Long Key" decryptionKey="Another Long Key" validation="SHA1" decryption="AES" /> Just leave this as is.
EnableDevStorage - Default: false Since we are deploying to Azure Hosted Service leave this as is. You only want to enable development storage when testing locally.
allowInsecureRemoteEndpoints - Default: true The site will be running a standard HTTP connection, so leave the value set to true.
Hostheader - Default: (blank) The hostheader is blank by default and for this guide it can be left blank as we will only deploy one Umbraco site that will respond to whatever URL is generated by Azure.
Diagnostics - Default: ApplicationName=Umbraco;EnableLogging=true;DiagnosticsConsole=false;RealtimeTracing=false;LogFilter=Verbose;LogTransferInterval=5;BufferQuotaInMB=512 This string determines how diagnostics will be handled by Accelerator when deployed to Azure. As you can see logging is enabled, which is fine for now so just leave it set to default value. But maybe consider if the buffer should be set to something smaller then 512MB.
DiagnosticsConnectionString - Default: UseDevelopmentStorage=true If you want to use diagnostics you have to change this setting to an Azure Storage account. This would typically be the same credentials as entered in AcceleratorConnectionString and when done your connectionstring would look similar to the one below: DefaultEndpointsProtocol=http;AccountName=YourStorageAccountName;AccountKey=YourStoragePrimaryAccessKey Note that official documentation states that diagnostics should run on https (for DefautlEndPointsProtocol), but you will be able to deploy it with http.
DiagnosticsServiceBus - Default: ServiceNamespace=enterservicebus;ServicePath=diag/umbraco;IssuerName=owner;IssuerSecret=enterissuersecret I must admit I'm not totally confident about this setting, but I believe the idea is to have a ServiceBus that keeps an eye on the Instance and writes errors to storage. You will probably have to setup a ServiceBus via AppFabric, but leave this for now as its not needed to succesfully deploy the Umbraco solution to Azure. I will write a follow-up blog post where I hope to have some more answers about this setting ;)
AcceleratorDrivePageBlobUri - Default: cloud-drives/Umbraco.vhd Also a default setting that you don't need to change. This is the location used for the VHD in storage.
Endpoints: HttpIn - Default: 80 Leave this setting set to default value.
HttpInAlt - Default: 8080 Leave this setting set to default value.
Local Storage: LocalStorage - Default: 16384 This local storage refers to the actual instance's (Azure VM) local storage size, which will typically be used for ASP.NET caching and IIS temporary files.
CloudDriveCache - Default: 2048 This setting is the size in MB used for the common storage for mounted cloud drives.
DiagnosticLogs - Default: 16384 This setting is the size in MB used for temporary storage for trace files and event logs created by Accelerator. All of these local storage settings can be left set to default values. But keep in mind that you might want to revise these settings for a production site.
4.) Now that the various settings has been updated you are ready to build the solution and publish the packages. But first you want to make sure you build release assemblies - see screenshot below:
So build the solution, which produces a Publish folder in your Accelerator solution folder:
Now go back to Visual Studio and right click Publish from the AcceleratorService project. This will open a new dialog like the one in the screenshot below.
Choose "Create Service Package Only" and click OK. The output folder will open automatically, so note the location of the two files (see screenshot below) as they will be used in step 6.
5.) Now its time to build the VHD and upload it to storage using AccelCon.exe (located in Publish folder in your Accelerator solution folder) from Windows Azure SDK Command Prompt. Note that you have to run the Azure SDK Command Prompt as administrator, so select the Windows Azure SDK Command Prompt from Start -> All Programs -> Windows Azure SDK v1.2 and right click "Run as administrator". Once you got it open you need to naviate to the Publish folder which contains the AccelCon.exe file. Type in this command and follow the instructions in the Command Prompt window: AccelCon /u /w /q This will start the creation of the VHD, copying of Umbraco solution to VHD and finally uploading it to your storage account.
6.) Final setp is to setup a Hosted Service and install the two published packages (AcceleratorService.cspkg and ServiceConfiguration.cscfg). Go to the WindowsAzurePlatform portal and Navigate to "Hosted Services, Storage Accounts & CDN" -> "Hosted Services". From the top menu click "New Hosted Service" and a new dialog will appear. Fill out the form similar to the screen below, but note that the URL prefix has to be unique from anything that is already deployed to azure. But don't worry it'll give you an error message if you choose a URL prefix that is already in use.
You can choose to deploy to staged environment or directly to production. For this guide you can choose either one. If you choose the staged environment you will get a random URL that you can use to test your hosted service (Umbraco solution) and you can later choose to promote that service fra staging to production.
Choose the same region as you chose for you Storage Account and browse and locate the two packages: AcceleratorService.cspkg (package localtion) and ServiceConfiguration.cscfg (configuration file).
After clicking OK you will most likely get a warning message if you have only set one instance in the configuration of the AcceleratorWorkerRole. It will take some time for the Hosted Service to initialize and startup the instance with VHD attached. While waiting you will see the following in the main window of the WindowsAzurePlatform portal:
And when your solution has been succesfully deployed to Azure Hosted Service it will look like this:
You should now be able to access the site via the standard url with your selected url prefix: YOURPREFIX.cloudapp.net.
I have deployed my Umbraco solution to umbracoazurecws.cloudapp.net (with CWS installed of course - this is my special dedication to Warren Buckley for trying to deploy Umbraco to Azure). Please note that this site will only be running for a couple of days, as I'm paying for each hour the instance is active :-S
That wasn't too bad was it ;-)
I hope you have found these two posts about deploying Umbraco to Windows Azure useful, and if you have any additional questions or think something is missing in this guide please feel free to drop a comment.
Update: Okay, maybe I should have deployed this demo site to two large or extra-large instances because now the site just loads like crap :-)
2nd Update: Deploying with two instances seems to work a lot better.
3rd Update: Please disregard the 2nd update - deploying an Umbraco site with multiple instances will not work, as you can only mount the Cloud Drive on a single instance. Multiple instances will only work with snapshots, which doesn't do Umbraco any good - see this Codeplex discussion for reference.
Trackbacks
- Umbraco BE Festival | These Days Labs | http://labs.tdlinx.be/2011/03/18/umbraco-festival/
Discussion