Although you can find a tutorial regarding Deploying Orchard to Windows Azure at Orchard project web page, but I found that the page is not so friendly for those who came across Windows Azure for the first time. So I re-write part of the tutorial especially for those who used / learn Windows Azure for the first time. I also include screen shot for each step so that you know where to click and so on.
This tutorial divided into:
- Building Orchard Package
- Setting Up Windows Azure Storage Account
- Setting Up Azure SQL Database
- Setting Up Windows Azure Hosting
- Moving From Local Host to Windows Azure
Building Orchard Package
This section show you how you can download the latest Orchard’s project source code and build the Orchard package for Windows Azure. If you want the Orchard package that I had already build, you can grab it here (Build on 17th of May 2011) or through official website and jump to step 7 instead.
Step 1: Download and install TortoiseHg. Tortoise will be used to download the source code from CodePlex where the Orchard project’s source code store.
Step 2: Create a folder to store the Orchard project’s source code (for example C:/OrchardEnlistment). Then goto the folder and Right-Click > TortoiseHg > Clone
Step 3: As the URL of the source, type “https://hg01.codeplex.com/orchard“. Then click Clone to start copy. Wait until the copy finish.
Step 4: Run Visual Studio Command Promot (2010) in administrator mode. Visual Studio Command Promot (2010) is came together with Visual Studio 2010.
Step 5: Go to the folder where you just download the Orchard source code, and run ClickToBuildAzurePackage.cmd. Then wait until the build complete.
Step 6: When the command completes successfully, the Orchard package for Windows Azure will be available under the artifacts folder (artifactsAzureAzurePackage.zip).
Step 7: Unzip the AzurePackage.zip file. You should have Orchard.Azure.Web.cspkg and ServiceConfiguration.cscfg
Setup Windows Azure Account
First, you need to sign in to Windows Azure Platform (https://windows.azure.com/) first before taking any step below.
Setting Up Windows Azure Storage Account
Step 1: Goto Hosted Service, Storage Account & CDN. We need to create a storage to store file or image for Orchard at Windows Azure.
Step 2: Click on New Storage Account to create a new storage for Orchard. You can also click on Storage Accounts to use any existing storage account that you had created before for Orchard.
Step 3: Enter a unique URL for your storage. Then select Create or choose an affinity group and choose Create a new affinity group. Although you can just select a region where you want to host your storage, but create an affinity group will help automatically optimize the location of your storage and azure instance.
Step 4: Enter a name for new affinity group, for example “orchard” and select the location you want to host the storage account and your azure instance later. Then click OK to create the affinity group and click OK again to create the storage account.
Step 5: You should see the storage account you created under the list of your subscription.
Step 6: Go back to the Orchard package that we build just now. Open ServiceConfiguration.cscfg for edit. Notepad will be good enough.
Step 7: We need to replace <Setting name=”DataConnectionString” value=”UseDevelopmentStorage=true” /> with the storage account setting that we had just created. Copy the line below and replace with the original setting (Make sure the open quotation and close quotation is the same with other in the configuration file, some user fail to upload the file later on due to the open and close quotation used was not recognized by xml).
<Setting name=”DataConnectionString” value=”DefaultEndpointsProtocol=https;AccountName=your-account-name;AccountKey=your-account-key” />
Step 8: Replace your-acount-name with the URL that you had given to the storage account (name of your storage account) you had just created and replace your-account-key with your storage account primary access key or secondary access key. You can find those information at your Windows Azure storage account properties.
Step 9: After edit the ServiceConfiguration.cscfg, save it.
Setting Up Azure SQL Database
Step 1: Goto Database. We need a SQL database to store Orchard setting like user login information.
Step 2: Select your subscription account and then click on Create to create a SQL server under your subscription account. Skip step 2 – 6 if you already have the SQL server on your azure.
Step 3: Select the region where you want to host your SQL database. Please use the same region with your storage account for optimize performance and cost. Then click Next. Step 4: Enter Administrator login and password for your SQL database. We will need this later when we setup Orchard. Then click Next.
Step 5: Check Allow other Windows Azure services to access this server. If you would like to access this SQL database from your local machine, you need to add your local machine IP address by pressing Add button (you can do that later if you think you want to access the database from your local machine). Then click Finish to create the Azure SQL database.
Step 6: You should see your Azure SQL database listed when it is successfully created.
Step 7: Select your SQL server you had just created and then click on Create to create a SQL database under your subscription account (Click the create under the database not the server).
Step 8: Give your database a name and click OK.
Step 9: You should see your database created when you hit OK.
Setting Up Windows Azure Hosting
Step 1: Goto Hosted Services, Storage Accounts & CDN. We need to create a hosted service to host Orchard in Windows Azure.
Step 2: Goto Hosted Services and then select New Hosted Service.
Step 3: Do the following step by step.
- Enter a name for your Windows Azure instance and URL (you will access Orchard through this URL later).
- Select the affinity group you created for your storage account or select a region where you want to host your service if you did not create any affinity group just now.
- Use Deploy to stage environment if you don’t want other to access your Orchard hosting easily (Windows Azure will create a very long unique URL for you to access) or use Deploy to production environment where everyone can access to your Orchard hosting through the URL you given just now.
- Give a deployment name for this hosting, for example “My First Orchard at Azure”.
- Browse for Orchard.Azure.Web.cspkg that we had build just now in Package location.
- Browser for ServiceConfiguration.cscfg that we had edited just now in Configuration file.
- Finally click OK.
Step 4: A warning dialog might be popup saying about only 1 instance of Windows Azure will be created. Just ignore that and continue to create our hosting service.
Step 5: It may take a while for the package to upload to Windows Azure, install and start the instance. Meanwhile, go grab a coffee while waiting. When the status change to Ready, mean your Orchard is ready to use. You can access your Orchard website by following the DNS name.
Setting Up Orchard on Windows Azure
Step 1: Enter the URL where you host your Orchard project on Windows Azure. You can find the URL at DNS name on your hosted service’s properties. You should see the Orchard setup screen.
Step 2: Enter name of your site, user name and password. The select Use an existing SQL Server (or SQL Express) database. See the next step 3 to 5 if you don’t know what to enter for the connection string.
Step 3: Go back to your Windows Azure platform. Goto Database, expend your subscriptions and server then select the SQL database you had created just now.
Step 4: You should see the SQL database properties on the right with Connection Strings field. Click on the button.
Step 5: Copy the ADO.NET connection string to Orchard setup page. Remember to change myPassword to your password for your SQL database.
Step 6: After you have enter everything on the Orchard setup screen. Click Finish Setup and wait for a while. Your Orchard page should be ready after that!
Moving From Local Host to Windows Azure
If you had already build your website on Orchard at your local host and now you want to move to it to Windows Azure, you might think that you need to work from zero again. Actually you can export some of the post and setting problem local host and import it to your Orchard at Windows Azure (after you setup Orchard at Windows Azure first). By default, import and export module is installed but disable.
Step 1: Goto Modules in your Orchard.
Step 2: Look for Import Export and Enable it if it is disable.
Step 3: After you enable Import and Export, you will see it is available on your left menu. Goto Import/Export.
Step 4: Now you can export your Orchard setting and data from your local machine to Windows Azure. You need to enable Import Export feature on both side as well. Remember to install all necessary modules because Import Export don’t include modules installation, you need to install manually before import.
That all for the tutorial, hope it can help those who use Windows Azure for the first time.
by Ooi Keng Siang via Ooiks’s Blog