Additional codelabs cover deploying a custom domain name and SSL certificate. link
Today, Amezmo supports .NET Core 3.1, .NET 5, and .NET 6 applications running in Linux containers. This codelab was written using the .NET Core SDK version 3.1.411 on .NET Core runtime 3.1.17. You can also use .NET 5 or .NET 6.
If you prefer to use Visual Studio or Visual Code to develop your application, you can. This codelab demonstrates using command line tools in a command prompt (shell). In future codelabs, I plan to demonstrate deploying applications to Amezmo using Visual Studio and Visual Code.
Note: These SDKs are included with Visual Studio. Check that you have a current version installed.
dotnet --list-sdksExample output:
3.1.411 [C:\Program Files\dotnet\sdk] 5.0.302 [C:\Program Files\dotnet\sdk] 6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]
Download and install the .NET Core 3.1 SDK.
Download and install the .NET 5.0 SDK.
Download and install the .NET 6.0 SDK.
If you do not already have an Amezmo account, go to amezmo.com to sign up.
If you have a coupon code go to credits to apply your code after creating an account.
GitHub is an amazing platform that provides project repositories that integrate with source code control tools. You will need a GitHub account to deploy applications to Amezmo.
Go to github.com and create an account. If you already have an account, skip this step.
The GitHub CLI provides several features for creating and managing your GitHub repositories. Without the CLI, repositories must be created using a web browser.
Download and install the CLI.
Browse the documentation to review the commands and features.
After installing the CLI, authenticate the CLI with your GitHub account.
gh auth login
The Git CLI provides the command line interface to GitHub. Git is an open source distributed version control system. We will use Git to push project and code changes to GitHub which will then automatically deploy to Amezmo.
Download and install the CLI.After installing the CLI, authenticate the CLI with your GitHub account.
Once you have created the required accounts and installed the developer tools, either restart your command prompt or reboot your system. The tools modify your environment which requires restarting command prompts.
Once you create a new Amezmo account, you will be presented with an interface to deploy an application.
Do not select an application type. Instead setup your account. Located top right of the window, click the account wheel next to Support.
From the menu select Profile. Setup your profile and account security.
From the menu select Billing, and then to Payment methods. Setup your payment methods and optionally invoice settings.
You can review your estimated bill at any time, go to Billing and then to Estimated bill.
If you have a credit code, go to Billing and then to Credits. Enter the promotion code.
For each deployed application, Amezmo provides a nice interface to manage and monitor your application. Compared to the major cloud vendors, this well-designed interface is very easy to work with and requires significantly less training.
In this part we will build a simple ASP.NET Core web application. Amezmo's support for .NET is very good and most applications can be ported to run as an Amezmo application with no changes.
Create a directory for your project. In this codelab, we will use c:\development\webapp
.
mkdir \development\webapp cd \development\webapp
Use dotnet command line tool to create your application:
.NET Core 3.1:
dotnet new webapp --framework netcoreapp3.1 --no-https
.NET 5:
dotnet new webapp --framework net5.0 --no-https
.NET 6:
dotnet new webapp --framework net6.0 --no-https
Notice the flag --no-https
. Amezmo provides a proxy in front of your application that provides support for HTTP and HTTPS. Your application only needs to support HTTP.
IPv6 Support:
Amezmo does not support IPv6. To prevent a warning about IPv6, change applicationUrl
in Properties\launchSettings.json
to only listen on IPv4 localhost HTTP port 5000:
"applicationUrl": "http://127.0.0.1:5000",
You can test the app by running it locally with the command dotnet run
. You should see the application listening on port 5000:
dotnet run info: Microsoft.Hosting.Lifetime[0] Now listening on: http://127.0.0.1:5000 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\development\webapp
While developing my application, I like to use the watch feature. Each time I change a source file, dotnet run will restart.
dotnet watch run
The IPv6 notice is written to the Amezmo logs. On the main application interface is the Logs tab.
On the Logs tab is the log file /logs/dotnet-production.log. Click the log name to see issues starting the .NET application instance.
Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Address not available'.
In this step, we will create a GitHub repository and put our project's files under source code control.
This requires the following tools are installed on your system. Both tools run from the command line. Amezmo also supports using Visual Studio and Visual Code in addition to these command line tools.
Initialize an empty git repository:git init Initialized empty Git repository in C:/development/webapp/.gitOptional: setup Git with your name and email address:
git config --global user.email username@example.com git config --global user.name "John Doe"Authenticate the GitHub CLI. You will need your username and password.
gh auth loginCreate a private repository on GitHub. Remove
--private
if you want the repository to be public.
gh repo create mywebapp --private ? Would you like to add a .gitignore? Yes ? Choose a .gitignore template VisualStudio ? Would you like to add a license? Yes ? Choose a license MIT License ? This will add an "origin" git remote to your local repository. Continue? Yes Created repository jhanley-com/mywebapp on GitHub Added remote https://github.com/jhanley-com/mywebapp.gitAdd all of the project's files. Files specified in the .gitignore will be skipped.
git add --allCommit the files.
git commit -m "Initial Project"Push the files to GitHub.
git push -u origin masterYour project is now under source code control in GitHub. Next, we will configure Amezmo to pull your project files from GitHub and deploy and application. Each time you commit and push files to GitHub, Amezmo will redeploy your application.
An Amezmo Application Instance is a Linux container running on an EC2 instance at AWS. Amezmo provides SSH access to the container, which I will cover in a separate article. The container provides Nginx, MariaDB, Redis, .NET Core, and Git. Whereas other vendors deploy the application and container as one unit, which is recreated each time you deploy an update, Amezmo creates a long lifetime container and uses file system symbolic links to switch deployments. This feature allows zero downtime for application updates and simple rollbacks on failures.
Once you have created an account, create a new application. Click "Add application".
Choose ".NET".
Amezmo currently supports four regions: Australia, Canada, United Kingdom, and the United States.
Select the .NET version. Currently .NET Core 3.1 and .NET 5.0 are supported.
Make note of the MariaDB settings for later use.
For this codelab, select "Business". We will need access to several features that are not available for the "Hobby" or "Developer" instance types. Amezmo supports changing the instance type at any time with no downtime.
After you click "Launch", Amezmo will deploy a container for your .NET Core application.
Once this completes, you will be presented with a screen to select a Git provider. We will deploy a Git provider in the "Deploy to Amezmo" step next.
In this step, we will connect the GitHub repository created in step 5 with our Amezmo .NET Core application.You will need your GitHub credentials and the name of the repository to deploy.
Click on the "Git" tab. Three Git providers are displayed. Select "GitHub".
The next step is to continue to GitHub to authorize Amezmo to access your code repository. Click Continue to GitHub.
Review the permissions that GitHub is granting to Amezmo. Click Authorize amezmo.
Once Amezmo is authorized, select the GitHub repository and Branch. Normally, the .NET Public domain root should be left at /wwwroot.
Next, select the Deployment type. To enable automatic deployments after new commit are made, select Yes.
Once you click Start deployment, Amezmo will pull the repository from GitHub and deploy your code to the application instance.
Review the status of the deployment.
In this step, we deployed our application source files to our Amezmo application instance. Located on the "Domains" tab is the internal domain. Launch a web browser to view your application.
Now that your application is deployed to an Amezmo application instance, updating the application is very easy.
In your favorite editor, edit the application file Pages/index.cshtml. Replace the contents with the following:
@page @model IndexModel @{ ViewData["Title"] = "Home page"; } <div class="text-center"> <h1 class="display-4">Welcome</h1> <p>.NET running on Amezmo</p> <div>
In a command prompt, execute the following GitHub commands:
git add . git commit -m "Updated my application".
The previous command stages the changes. Now we will push the changes to GitHub. The GitHub repository will be updated and a notification will be sent to Amezmo. Amezmo will pull the changes and redeploy your application. This process takes about one minute.
git push
In this codelab, we deployed an example .NET application. The next step is to secure that application with a custom domain and HTTPS. This step is covered in the codelab Configure Domain and SSL