It is easier to deploy an ASP.NET Core app on Azure Web Service because we don’t need to manage a virtual machine in this case. But some times we need full control on our environment and for that virtual machine on Azure is the option.
Below is the steps to deploy (framework dependent deployment) and run an ASP.NET Core app on an Azure virtual machine.
- Create a new ASP.NET Core app with Visual Studio or .NET Core CLI.
- Build and run the app from local machine.
- Login to Azure portal and create a virtual machine with Windows Server 2019.
- Login to the virtual machine with remote desktop connection.
- Install IIS from Server Management (add or remove features).
- Install ASP.NET Core Hosting Bundle.
- Deploy the ASP.NET Core app as framework dependent deployment to a local folder in your machine.
- Create a folder in the local drive of the virtual machine.
- Copy the deployment output from your local machine to the virtual machine.
- Open IIS management studio and create a new app pool with your Windows admin user credentials. The .NET runtime version of the app pool will be ‘no managed code’. The identity of the app pool will be ‘local user’.
- Create a new website and use the new app pool. Attach the location where you placed the deployment artifacts.
- Browse the newly created website and it should work fine.