Deploying an Episerver site to the Amazon cloud

After deploying a gazillion Episerver sites to Azure I thought it would be nice to play with Amazon AWS Elastic Beanstalk. Only because I wanted to see if it is just as easy to deploy a website to AWS as it is with Azure.

The documentation on Episerver World is quite extensive, however some pieces seem to be missing and there are some pitfalls, so I hope this blogpost will help you out with your deployments.

Here is what we are going to do:

  1. Create a free AWS account
  2. Create a user for this deployment
  3. Install AWS Toolkit in Visual Studio
  4. Setup the database instance
  5. Prepare the database
  6. Prepare the solution (Alloy)
  7. Deploy to AWS Elastic Beanstalk

1. Create a free AWS account

If you already have an AWS account you can skip this step.

Goto https://aws.amazon.com/ and select “Create free account”. After you have been validated you end up in the AWS console.

2. Create a user for this deployment

Amazon recommends not to use your root account for day-to-day interaction with AWS, because it has unrestricted access to all your resources. So let’s create a new user.

In the AWS console, select Identity and Access Management.

Select users in the menu and click “Create New User”
Enter the username(s) you want to use and click “Create”.

AWS-2-1

Download or copy the User Security Credentials, you will need them later for creating a profile in the AWS Explorer and configuring the providers.

Select the created user and click “Manage Password” in the User Action drop-down menu.

Enter a password for the user.

Next create a group, for example “Episerver” and attach the appropriate policies to this group.
We will use the following resources: Elastic Beanstalk, EC2, RDS and SNS/SQS. Adding AWSElasticBeanstalkFullAccess will give us the correct rights.

Finally add the user(s) to the group and we are ready to go.

The username and password you just created will be used to login to the AWS console the next time.

The login url is displayed in the dashboard page and should look like: https://12345678.signin.aws.amazon.com/console

You can change the account number for some custom name if you want.

Logout the root account.

3. Install AWS Toolkit in Visual Studio

The AWS toolkit is an extension for Visual Studio that lets you manage your resources in AWS and makes it easy to deploy.

Go to http://aws.amazon.com/visualstudio/ to download the latest version of the AWS toolkit.

After installation you can create a new profile in the AWS Explorer by using the security credentials we saved earlier.

AWS-3-1

4. Setup the database instance

You can either setup the database instance from the AWS Console or from Visual Studio.
Be sure to select the right region for your resources.

Using AWS Console:

Login with the security credentials you just created.
In the AWS console go to RDS

AWS-4-1

Create a new database instance of type SQL Server Express.

As the DB Instance Class select db.t2.micro, because that one is free and will do fine for this demo.

You can leave the rest of the instance settings to the default.

At settings specify a name for your database instance and enter a master username and password.

In the next step at “Configure Advanced settings” you can use the default settings. Be sure “Publicly Accessible” is set to YES, else you won’t be able to connect to your DB instance from Visual Studio or SQL Server Management Studio.

Click “Launch DB instance” to start your database server.

AWS-4-2

Using Visual Studio:

In the AWS explorer right click on Amazon RDS and select “Launch Instance”.
This will open up a wizard.

Select SQL Server Express.

Select the DB Engine version you need.

As the DB Instance Class select db.t2.micro, because that one is free and will do fine for this demo.

Specify a name for your database instance and enter a master username and password.

AWS-4-3

In the next step be sure to check the “Publicly accessible” option, else you won’t be able to connect to your DB instance from Visual Studio or SQL Server Management Studio.

Also check “Create new security group”. This will create a new security group which includes your IP address, so you can access the DB instance.

You can leave the rest of the setting to their default values.

AWS-4-4

5. Prepare the database

Now that we have our DB instance up and running, we can create the database.

In the AWS Explorer in Visual Studio right click the DB instance and select “Create SQL Server Database”.

When the database is created we we automatically be taken to the Server Explorer.

AWS-5-1

6. Prepare the solution (Alloy)

In Visual Studio create a new Alloy project. Do not include search in the project.
Add the following package to the solution: EPiServer.Amazon.

In the web.config file we have to add 2 items to the episerver.framework section:

Blob provider

You will need the accessKey and secretKey from the user we created in step 2.
Information about the region code can be found here: http://docs.aws.amazon.com/general/latest/gr/rande.html#rds_region
For the bucket you can take any name you want. The bucket will be created automatically after deployment if it doesn’t exist.

Event provider

You will need the accessKey and secretKey again from the user we created in step 2.
Information about the region code can be found here: http://docs.aws.amazon.com/general/latest/gr/rande.html#sns_region
For the topic you can take any name you want. The topic will be created automatically after deployment if it doesn’t exist.

We also have to configure the correct connection string. It should look like this:

You can find the name of the server by right clicking on the instance and copy the address, or by looking at the properties.

Note: normally I would not recommend to use the sa user for connecting to the database. You can easily create a new user by using SQL Server Management Studio.
For now we will use the sa account.

AWS-6-1

As a final step before deployment we need to install the database schema.
Open the SQL script from: packages\EPServer.CMS.Core.x.y.z\tools\EPiServer.Cms.Core.sql and execute it against the database.

Now we are finally ready for the real deployment.

7. Deploy to AWS Elastic Beanstalk

Right-click on the project and select “Publish to AWS”, the publication wizard will open.

Select the right profile and region and select “Create a new application environment”.

AWS-7-1

Enter a name for the application, environment and url, or choose one of the defaults.
AWS-7-2

You can leave most of the AWS settings to their default. Be sure instance type is set to t2.micro, because that’s the free one.

At Relational Database Access select the security group for your VPC

AWS-7-3

Leave Application Options also default for now.
AWS-7-4

Review all the settings. When everything is ok, press Deploy
AWS-7-5

 

After the deployment you might run into a few issues.

Access to the path ‘C:\inetpub\wwwroot\modules\_Protected\repository.config’ is denied
By default the application pool user is not allowed to write to the disk. A workaround for this issue is to run the site locally once and include the generated repository.config file in the project. Then redeploy the site.

Another option is to create a folder in the root of your project named “.ebextensions”.
In that folder create a config file, for example AlloyEB.config and add the following lines to it:

 

  • K Khan

    Cool

  • Steve

    What license are you using? The perpetual licenses are tied to IP or MAC address, seems like that might be a challenge with an elastic beanstalk environment. Thanks for the write-up.

    • Mark van Dijk

      Hi Steve,
      For this demo I used an “EPiServer 7 Cloud Developer License” which are available for partner developers.