Intro
This post describes running EPiServer CMS version 6 on the Windows Azure using Virtual Machine (VM) Role Beta Program. The main goal was to take developer Hyper-V machine and deploy it to the cloud as staging environment.
Prerequisites
- Windows Azure account
- VM Role Beta Program enabled (it took over a month to complete)
- basic EPiServer knowledge
- SQL Server 2008 R2
- Microsoft SQL Server 2008 Feature Pack is required by database migration tool (SQL Azure Migration Wizard)
- Visual Studio 2010 or Microsoft Visual Web Developer 2010 Express
- Windows Azure SDK and VS Cloud Service installed
Creating VHD
First Windows Server 2008 R2 is required - I've used Windows Server 2008 R2 Enterprise (Full Installation). Additionally it should be installed on a single partition, which is not the default behaviour. There are few posts on how to remove this additional partition but sysprep (described later) fails after those operations - it can be done only during system installation.
- select Custom (Advanced) instead of Upgrade
- on partition selection screen press Shift + F10 to open console
- run diskpart
- list disk
- select disk 0
- create partition primary
- exit
- close console
- refresh
- select created partition
After installation go to Server Manager:
- add Role: Web Server (IIS)
- add Feature: .NET Framework 3.5.1 (inside .NET Framework 3.5.1 Features node)
You may backup Virtual Machine now to reuse it later.
Installing Application
Now it's time to install EPiServer or any other application you'd like to deploy to the could. I've used empty EPiServer version 6 with Public Templates. Only web.config change was to switch to SQL Role and Membership providers.
Setting up database
Local database needs to be migrated to Microsoft SQL Azure Database - there's quite simple way to do it using SQL Azure Migration Wizard
Because this tool doesn't clean tables previously filled with data this script can be used to remove all tables if another run is required for any reason.
You should modify connectionStrings.config to connect to Azure SQL instance and test if application works.
Finalizing VHD
It's highly recommended to backup Virtual Machine now.
Further steps caused it hang during start up until in cloud.
Mount C:\Program Files\Windows Azure SDK\v1.3\iso\wavmroleic.iso as DVD drive and install WaIntegrationComponents-x64.msi. Provide it with valid Administrator password and let it install all the drivers it needs. After reboot run %windir%\system32\sysprep\sysprep.exe enter options as on image below and let Virtual Machine shutdown - now VHD image is ready for deployment.
If you ever start this Virtual Machine again (which is not obvious to succeed) you need to launch sysprep once more.
Creating Management Certificate
- Start Visual Studio
- create project of type C# / Cloud / Windows Azure Project.
- click Publish
- Select 'Deploy your Windows Azure project to Windows Azure'
- Credentials - select Add... and name it
- Click 'Copy the full path' to get Public key path and upload it to Azure
- Copy subscription ID back to Management Authentication dialog and click OK - it will be verified.
- You can now forget about this project :).
Uploading VHD
Open a Windows Azure SDK Command Prompt as an administrator from Start | All Programs | Windows Azure SDK v1.x.
Run command below replacing XXXXX and YYYYY with your Subscription Id and Certificate Thumbprint respectively. You should of course provide path to VHD and destination location to reflect your needs.
csupload Add-VMImage -Connection "SubscriptionId=XXXXX; CertificateThumbprint=YYYYY" -Description "Base image Windows Server 2008 R2" -LiteralPath "D:\VM\AzureTest\Virtual Hard Disks\Clean win 2008 r2.vhd" -Name baseimage.vhd -Location "North Europe"
Anywhere locations are not supported (i.e. Anywhere Europe and Anywhere US).
Statuses visible in Management Portal while uploading:
- pending means uploading
- committed means ready
Creating the Service Model (Visual Studio part)
- Start VS2010
- create Windows Azure Project without any roles
- right-click Roles > Add > New Virtual Machine Role
- in properties of new role > Virtual Hard Disk tab > select account and uploaded VHD
- in Endpoints tab add:
- name: HttpIn
- type: Input
- protocol: Http
- public port: 80
- private port: 80
- go to Publish
- Configure Remote Desktop (save certificate to file WITH the private key)
- select Create Service Package Only
- click OK
Creating the Service Model (Management Portal part)
- New Hosted Service - name it, give it URL prefix, choose region and 'Do not deploy'
- Add Certificate (select one created in previous step)
- New Production Deployment - name it and select two files created by VS (.cspkg and .cscfg)
- wait...
- wait more...
- wait even more...
- you can connect to IIS using URL on the right
- Connect on the ribbon downloads RDP file
Further works
All file system modification on Virtual Machine will be lost when it's reimaged from uploaded VHD. It may happen because of machine failure or restart. At the moment only data stored in Azure SQL is safe - every change to VPP will be lost. There are two options - to store VPP data in database or in Cloud Storage. There's a post on this by Daniel Berg but I haven't tried yet.
There's also licensing issue as EPiServer license is linked either to IP or MAC address. Unfortunately MAC address changes as well during deployment. At the moment I've generated new demo license using MAC address obtained from Virtual Machine but it will be lost. Not sure what can be done about it.
No comments:
Post a Comment