This is a note to reminding me how to publish ASP.NET Core website to AWS via Visual studio.
PS: My Visual studio version is Enterprise 2017. Hope it also helps you, good luck.
Step 1: AWS setting
If you already create a user and add access policy for that user, please go to step 2.
If you don’t have an AWS account, click the link to create an AWS account:
Please note that to authorize your AWS account, you have to bind a valid bank account to your AWS account which can use online and it has at least $1.
After your AWS account was authorized, login to your account ‘Service’ -> ‘Security, Identity & Compliance’ -> ‘IAM’
In the left-hand side, select ‘Groups’ -> ‘Create New Group’ (if you don’t want to put the user in a group, you can create a new user and attach policy directly.)
Input your group name, click ‘Next’ to attach policy, select ‘AmazonEC2FullAccess’ & ‘AWSElasticBeanstalkFullAccess’
After you created group, select ‘User’ in the left-hand sidebar, click ‘Add New User’, input user name, the access type chose ‘Programmatic access’
Add user to the group, it’s ok if you don’t have a group, but don’t forget to attach access policy for your user, just the same as attaching the access policy to a group.
After you add user successfully, you will have ‘Access key ID’ & ‘Secret access key’, remember this, you will need this for you AWS setting in visual studio.
Step 2: add database
go to ‘Service’ -> ‘database’ -> ‘RDS’ -> ‘Instances’ -> ‘Lunch DB instance’
click ‘Lunch DB instance’ to create your database instance, if you don’t want to receive a bill about this, don’t forget to choose a free tier database, there is a filter box on the bottom of the page if you click that, the only free database is available.
set you DB instance info:
after DB instance created, click your DB instance, go to ‘security group’, click it
change your setting for DB access.
input the database setting to your file ‘appsetting.json’:
“DefaultConnection”: “Server=YourDBInstanceEndpoint;Database=YourDatabaseName;user id=YourMasterUserNameFromDBInstance;password=YourMasterPasswordFromDBInstance;”
Step 3: Visual studio setting
For configure the Visual Studio environment, you have to install ‘AWSSDK.EC2’ & ‘AWSSKD’
There are two ways to install ‘AWSSDK.EC2’:
The first is to install it via ‘Visual studio’ -> ‘Tools’ -> ‘NuGet package Manager’, you won’t have ‘AWS explorer’ in your VS.
Another way is to download ‘MSI Installer’. The installer will include the AWS Toolkit for Visual Studio and AWS Tools for PowerShell, you will get a ‘AWS Explorer’ in your VS.
Installing AWS Tools …
Install ‘AWS Toolkit’ via visual studio, ‘Tools’ -> ‘Extensions and Updates’
Once you install it, you see it in your ‘Extensions and Updates’ -> ‘Installed’ page
All tools are installed.
Add profile to your ‘AWS Explorer’, click ‘+’, ‘New Account Profile’ window will show. Input a profile name, the have ‘Access key ID’ & ‘Secret access key’ is the keys you got from your ‘AWS’-> ‘IAM’-> ‘User’
Everything is done, let’s start to publish our website to AWS via visual studio.
Step 4: Publish the website to AWS via visual studio
Right click on your project, select ‘Publish to AWS Elastic Beanstalk’…
You can choose different account profile, for me, I just have one profile which connects to AWS account. You can choose ‘Redeploy to an existing environment’ or ‘new environment’
Check the URL is available or not
I create a new key pair, just click dropdown arrow -> ‘Create a new key pair’
The Deployed Application Permissions will auto fill-up for you
click ‘Next’ -> ‘Deploy’ button, it will start to publish your project, you can see this info from ‘AWS Explorer’
Once the project was done, the ‘AWS Explorer’ window will show ‘INFO Successfully launched environment: xxxxx’, you can click the URL shown in the top of the window.
My sample project was published successfully. So far, everything is done, enjoy your journey at C# .NET Core and AWS…
Any feedback is welcome! :-)
blog comments powered by Disqus