Create a Free Windows VM (B1s) server in Azure and host .Net Core website 2024
To create a free Windows VM in Azure (B1s tier) and install and host a .NET Core application, follow these steps:
Step 1: Create a Free Windows VM (B1s) in Azure
Login to Azure Portal:
- Go to Azure Portal.
- Log in with your credentials.
Create a Virtual Machine:
- Click on "Create a resource" > "Compute" > "Virtual Machine."
- Fill out the basics:
- Subscription: Select your free subscription.
- Resource Group: Create a new resource group or select an existing one.
- Virtual Machine Name: Give your VM a name.
- Region: Choose a region where the B1s instance is available.
- Image: Select "Windows Server 2019 Datacenter" or "Windows Server 2022 Datacenter".
- Size: Click "Change size" and select "B1s" (part of the free tier if you’re eligible).
- Administrator Account: Set a username and password for your VM.
Networking:
- Ensure that the VM has a public IP address to access it via RDP.
- Configure inbound port rules:
- Allow RDP (3389) to connect remotely.
- Later, you’ll also need to allow HTTP (80) and HTTPS (443) for web access.
Create the VM:
- Review and click on "Create" to deploy the VM.
- Wait until the deployment completes.
Step 2: Connect to the VM
- Connect via RDP:
- Once the VM is running, click on "Connect" > "RDP" in the Azure portal.
- Download the RDP file and open it.
- Use the credentials you set earlier to log in.
Step 3: Install .NET Core Hosting Bundle
Download .NET Core Runtime:
- Open a browser in the VM and go to the .NET Download page.
- Download the appropriate .NET Core Hosting Bundle (Runtime + IIS support) for your application.
Install IIS:
- Open Server Manager > "Add roles and features."
- Select Web Server (IIS) and proceed with the installation.
Install .NET Core Hosting Bundle:
- Run the .NET Core Hosting Bundle installer you downloaded.
- This will install the .NET Core Runtime and configure IIS to host .NET Core applications.
Step 4: Deploy and Host .NET Core Application
Publish .NET Core Application:
- On your local machine, publish your .NET Core application.
- Run the following command in your project directory:bash dotnet publish -c Release -o ./publish
- This will create a folder named
publishwith all the files required to run your application.
Transfer Files to the VM:
- Use Remote Desktop to copy the published files from your local machine to the VM, or use tools like WinSCP to upload them.
Set Up IIS to Host the Application:
- Open IIS Manager on the VM.
- Right-click on Default Website (or create a new one) and select Add Application.
- Set the alias, select the physical path (point to your publish folder), and choose the correct application pool.
- Ensure that the application pool is using No Managed Code since it is a .NET Core application.
Configure Firewall and Networking:
- Go to the Networking tab of your VM in the Azure portal.
- Add inbound port rules for HTTP (80) and HTTPS (443).
- Ensure the Windows Firewall on the VM allows these ports.
Step 5: Test the Application
- Open a browser and navigate to the public IP address of your VM.
- If everything is set up correctly, you should see your .NET Core application running.
This setup will allow you to host your .NET Core application on a free Windows VM using the Azure free tier.

Comments
Post a Comment