.NET Tutorial - Your First Microservice

Run your service

In your command prompt, run the following command:

In your terminal, run the following command:

Terminal
dotnet run

You should see an output similar to the following:

Command prompt
Building...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5020
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:\Users\Ana\MyMicroservice

Wait for the app to display that it's listening on http://localhost:<port number>, and then open a browser and navigate to http://localhost:<port number>/weatherforecast.

In this example, it showed that it was listening on port 5020, so the following image shows the URL localhost:5020/weatherforecast.

The API endpoint returns JSON data containing weather forecast information

Congratulations, you've got a simple service running!

Press CTRL+C on your command prompt to end the dotnet run command that is running the service locally.

Press CTRL+C on your terminal to end the dotnet run command that is running the service locally.

Got an error?

If you receive a message similar to No webpage was found for the web address: http://localhost:5020, ensure you are viewing the Weather Forecast page of your application. The URL should look like http://localhost:5020/weatherforecast and not just http://localhost:5020.

Continue