.Net Core 2.0 deployment on AWS

core 7

In my previous post, I have explained how to setup your .Net Core 2.0 which you can find here.

In this post, I will explain how to deploy your .Net Core 2.0 application into AWS Elastic Beanstalk.

First of all, let us see what is AWS Elastic Beanstalk?

AWS Elastic Beanstalk is an orchestration service offered from Amazon Web Services for deploying infrastructure which orchestrates various AWS services, including EC2, S3, Simple Notification Service (SNS), CloudWatch, autoscaling, and Elastic Load Balancers.

Please note that Elastic Beanstalk currently has Core 1.0 and it will be soon updated to have Core 2.0

If you want to know about the .Net Core 1.0 deployment then have a look here.

So I will explain what can be done to deploy your Core 2.0 application on Elastic Beanstalk until the platform is updated to support Core 2.0

All we need to do is to add aws-windows-deployment-manifest.json file into our Core 2.0 application.

aws-windows-deployment-manifest.json is used to instruct Beanstalk to install .NET Core 2.0 on the instance during deployment.

Add below lines into to aws-windows-deployment-manifest.json file:

{
  "manifestVersion": 1,
  "deployments": 
  {
    "aspNetCoreWeb": [
    {
      "name": "app",
      "parameters": {
      "appBundle": ".",
      "iisPath": "/",
      "iisWebSite": "Default Web Site"
    },
      "scripts": {
      "preInstall": {
      "file": "./Scripts/installnetcore20.ps1"
       }
     }
   }
  ]
 }
}

Basically, above lines instruct Elastic Beanstalk to deploy .Net Core application.

But we want to deploy .Net Core 2.0 application, so for that we need to execute the ./Scripts/installnetcore20.ps1 PowerShell script which is already mentioned in above json file.

Now we need to add this ./Scripts/installnetcore20.ps1 Powershell file into Core 2.0 application.

Add below lines into PowerShell file:

$localPath = 'C:\dotnet-sdk-2.0.0-win-x64.exe' if(!(Test-Path $localPath)) { Invoke-WebRequest -Uri 'https://download.microsoft.com/download/0/F/D/0FD852A4-7EA1-4E2A-983A-0484AC19B92C/dotnet-sdk-2.0.0-win-x64.exe' -OutFile $localPath & $localPath /quiet /log c:\InstallNetCore20.log }

Above script downloads the .NET Core 2.0 installer and run the installer from the Microsoft site.

As we know that many times it is possible that link is broken or changed so in this case another option is to put Core 2.0 installer into the S3 bucket of AWS application (I did that way)

Our .Net Core 2.0 application looks as below:

core6

Another way is using Docker image if your application is Docker basked.

If you know any other way then please suggest in below comment section.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s