Deploying to Amazon
This document describes how to set up an EPiServer CMS site to run on Amazon Elastic beanstalk but most should be applicable to Amazon Cloud Formation as well. In this scenario an Alloy sample site is created from the EPiServer Visual Studio plug-in (at least version 7.7), but most steps can also be applied to sites created in other ways. Refer to Elastic Beanstalk for more detailed information about Elastic Beanstalk and Cloudformation for more detailed information about Cloudformation The AWS (Amazon Web Services) Management Console requires an account with login details.
Note that deploying to cloud-based websites requires that each deployed application and module is designed for cloud.
The following applies to EPiServer CMS:
- A specific cloud enabled license is required. Refer to the EPiServer License Center for more information.
- Content Mirroring is not supported.
- Sites deployed with Elastic Beanstalk have by default no write access to the file system (for example Admin/System Settings that write to web.config does not work)
Cloud website setup
This is an example of setting up a CMS website running on a Elastic beanstalk web site environment with multiple instances. The web site instances share the same Amazon RDS (Relational Database Service) SQL instance, and the S3 storage in Amazon is used for storing of the file binary data. Load balancing is applied, and the SNS (Simple Notification Service)/SQS (Simple Queue Service) message queues manages events between the CMS websites. Note that deploying to cloud based websites requires that each deployed application and module is designed for cloud.
Using elastic scaling, the number of CMS sites can easily be increased or reduced depending on capacity needs at the time. This can be configured from the Elastic Beanstalk administration interface in AWS managment console.
When using Amazon Elastic beanstalk as described in this section, Add-ons should be installed on the machine locally and then deployed to Amazon together with the application. Reason for this is when an AddOn is installed it will only be present on the instance where it was installed meaning it will not be present on other instances of the site (in case elastic scaling is configured).
Creating Amazon resources
In this example resources is created manually from AWS Managment console. Another option is to create the resources from Visual Studio using the AWS Toolkit, see http://aws.amazon.com/visualstudio/. Yet another option is to define the resources in a cloudformation template and provision the resources through the template.
- When creating resources in Amazon AWS make sure you select the correct region in the upper right corner, you probably want your resources located in a data center closest to your main users.
- Consider creating two instances of each resource (e.g. RDS instance, Topic, S3 Bucket) or use two different accounts, one for development and one for production, to make it easy to switch between them simply by changing the configuration.
Creating an Elastic Beanstalk instance
In this example the Elastic Beanstalk instance is created while deploying the code to amazon from AWS toolkit. Another option is to create the Elastic Beanstalk application from the AWS managment console and then deploy against that application. In that case the RDS database instance can be optionally be created while creating the application (however to be able to connect to it from your local machine you need to add an inbound rule to the created security group that allows connection from your machine).
Creating a Security Group
- Open the AWS management console and select the option EC2 in the Services menu.
- Select Security Groups under Network & Security in the left menu.
- Click on the Create Security Group button, give it a name and a description and click Create.
- In the list select the created group and select Inbound tab in the lower panel.
- Select MS SQL from the rule dropdown and click on Add Rule and then Apply Rule Changes.
Creating an RDS SQL instance
- Open the AWS management console and select the option RDS in the Services menu.
- Click on the Launch a DB Instance button, and in the engine selection select sqlserver-web (or other Sql server option).
- In details view, provide identifier name, size, login user and password.
- In additonal config view select the VPC security group created previously and finish the wizard to create the db instance.
Creating an S3 storage bucket (Optional)
When running on Amazon, the media (for example images) should be stored in the S3 storage to enable elastic scaling.
Do the following to create a S3 storage account manually:
- Go to the AWS Management console and select S3 from the Services menu.
- Select Create Bucket in the upper right corner, and in the dialog select a region and give it a name.
Creating an SNS Topic (Optional)
To be able to scale the site to run on several instances, we need to set up an SNS Topic in Amazon to handle messages between the site instances.
Do the following to create an SNS topic:
- Go to the AWS Management console and select SNS from the Services menu.
- Click the Create New Topic button, and in the dialog select a name.
Installing a database
To create a new database in the RDS database instance you can connect to the instance from SQL Server Management Studio, the endpoint can be found in the AWS Management console under the RDS if selecting the previous created instance. First create a new database and then run the script from the EPiServer.CMS.Core package (i.e. [SolutionDir]\packages\EPServer.CMS.Core.7.6.0\tools\EPiServer.Cms.Core.sql) to install the CMS database schema to the database.
Installing workflow schema
If persistence of workflow instances is needed (if you plan to use workflows on the site) then you need to install the workflow schemas to the site. The scripts that needs to be installed is SqlPersistenceService_Schema.sql and SqlPersistenceService_Logic.sql which can be found in <windir>\Microsoft.NET\Framework64\v4.0.30319\SQL\en (you might get an error "<user> does not have permission to run DBCC TRACEON" but that can be ignored). Another option if you do not plan to use workflow is to remove theWorkflow persistence service from web.config, that is the entry with type SqlWorkflowPersistenceService under workflowRuntime/Services.
Removal of workflow persistance configuration in web.config:
<workflowRuntime EnablePerformanceCounters="false"> <Services> <add type="System.Workflow.Runtime.Hosting.DefaultWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" maxSimultaneousWorkflows="5" /> <add type="System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <strong>REMOVE THIS: <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35" UnloadOnIdle="true" /></strong> </Services> </workflowRuntime>
Disable workflows completely by adding the disabled attribute to the workflowSettings element [requires 7.14]
<episerver> (..) <workflowSettings disabled="true" /> (..) </episerver>
Creating a site
In Visual Studio, create a new project by selecting New...Project, and then EPiServer Web site. In the dialog select Alloy templates (either MVC or Web Forms). Uncheck "Add EPiServer Search", to use search functionality when running in Azure see section "Search in Amazon"
Install the NuGet packages EPiServer.Amazon to the project.
Updating the configuration
Add the following block to the episerver.framework section in web.config to map BLOB and event providers to Amazon:
<blob defaultProvider="s3blobs"> <providers> <add name="s3blobs" type="EPiServer.Amazon.Blobs.AmazonBlobProvider,EPiServer.Amazon" accessKey="<your accesskey>" secretKey="<your secretkey>" region="<region code>" bucket="mysitemedia" /> </providers> </blob> <event defaultProvider="amazonevents"> <providers> <add name="amazonevents" type="EPiServer.Amazon.Events.AmazonEventProvider,EPiServer.Amazon" accessKey="<your accesskey>" secretKey="<your secretkey>" region="<region code>" topic="mysiteevents" /> </providers> </event>
accessKey and secretKey should be replaced with the keys associated with your account. bucket should be replaced with the name of the S3 bucket created previously. topic should be replaced with the name of the SNS topic created previously.
The region attribute should be replaced with a AWS region code, for example "us-east-1". Other valid regions for the S3 and SNS/SQS services can be found in the AWS documentation on Regions and Endpoints.
Under the connectionStrings section, change the connection string EPiServerDB to the connection string from AWS Management console (see Installing a database). Remember to keep the setting MultipleActiveResultSets=true.
Deploying from Visual Studio
To be able to deploy to Amazon from Visual Studio, you need to install the AWSTools. AWSDeploy will use MSDeploy to package the application and by default it will only include the files in the project and bin folder. Make sure the modules and modulesbin folders are included in the project to make sure these as published as well.
Make sure that you in similar fashion also add any other folder containing files needed for your site thats not included in your solution.
Since beanstalk deployment uses MSDeploy the IIS Web site property for Package/publish setting should be set to "Default Web Site" before deploying. One way to acheive that is to add following line to the csproj file for the project: <DeployIisAppPath>Default Web Site</DeployIisAppPath>
To deploy to Amazon Beanstalk, you right-click on your project in Visual Studio and select "Publish to AWS...". In the wizard select Beanstalk as template and walk through the wizard. After the deployment is done you should be able to access your site through the URL created from the wizard. Updates are done in the same manner by selecting "Publish to AWS...". In the AWS Managment console under "Elastic Beanstalk" you can manage your application, for example redeploy a previous package or scale the number of web sites running the application.
From version 7.7 of CMS there is a bootstrap feature for content. It works so that if there is an export package located at "[SolutionDir]\App_Data\DefaultSiteContent.episerverdata" then during initialization that package is imported and a site is created. The bootstrap will only happen if the site does not have any previous content. For cloud deployment this means that it can be a good idea to first publish the project to the cloud environment before starting a local site configured against the cloud database. Then the bootstrap will happen in the cloud environment which is much faster (the site and database is likely in same datacenter) and also sets the SiteUrl to the cloud url for the created site.
An alternative way to transfer data to an EPiServer site running on Amazon is to use the EPiServer CMS Export/Import functionality. Export the start page from your local site and database and import on the site running in Amazon before continuing to the next step.
Creating an admin/edit user
To be able to login to the site on Amazon you need to create a user that has access to admin view and edit view. You do this by configuring MultiplexingRoleProvider and MultiplexingMembershipProvider as default providers to enable Windows authentication locally on your machine. Then browse the site locally but with the database connection string setup against the database in Amazon.
In the CMS admin view under Administer Groups, create two groups WebAdmins and WebEditors. Then create a user that is a member of both the created groups. Configure the site with SQL membership/role providers as default providers, and ensure that the created user can login and access admin mode.
Search in Amazon
When hosting in Amazon the best practice is to use a scalable search solution such as EPiServer.Find. Since EPiServer.Find is a hosted service that you connect to, it will work the same way as when your site runs on-premise.
If you want to use the built-in EPiServer.Search when running in Amazon the suggestion is to create a separate virtual machine, that is an EC2 instance and then install EPiServer Search on that instance. Then configure the application to use the search service runnning on the EC2 instance.
Session State in Amazon
The core parts of EPiServer CMS does not use Session State but some functionality does, such as some of the Visitor Groups criteria. There are two approaces to enabling session state, either use the sticky session feature (also known as session affinity) in the Elastic Load Balancer to make sure all requests from a user is reaching the same server combined with the default in-memory session state provider. Another approach to enable better scaling is using an optimized provider for Amazon, such as the session provider for Amazon DynamoDB.
- Deployment scenarios
- BLOB storage and and BLOB providers
- Event management and event providers
Last updated: Mar 31, 2014