Microservice studies project that manages the inventory of items in a catalog.
-
In File Explorer, click on the
Play
folder and create a folder calledBigai.Play.Inventory
-
Type the command
cd .\Bigai.Play.Inventory\
and press enter to change folder -
Type
code .
and press enter. This will open Visual Studio code in the workspace -
Right click under
Bigai.Play.Inventory
thenNew Folder
-
Type
src
, which is where the source code will be -
Right click on the
src
folder, thenOpen in Integrated Terminal
-
Type
dotnet new webapi -n Bigai.Play.Inventory.Service
and press enter
- Inside of
.vscode
folder, in thetasks.json
file add a group in the build section afterproblemMatcher
:
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
With this configuration, you can click Terminal
and then Run Build Task
and the project will be built. If you prefer, you can use the shortcut Ctrl + Shift + B
-
Right click on the
src
folder, then click onOpen in Integrated Terminal
-
Type
dotnet run
in terminal, under the source folder of project. To stop the project typeCtrl + C
To remove open browser when launch the application, in the lauch.json
file, remove or comment section serverReadyAction
, like this:
//"serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
//},
To avoid conflicts with other microservice that run using the ports 5000 and 5001, do like this:
-
In the
Properties
folder, open thelaunchSettings.json
-
Change the values of ports in the section
"applicationUrl": "https://localhost:5001;http://localhost:5000",
from5000
to5004
and from5001
to5005
, for example,
final result "applicationUrl": "https://localhost:5005;http://localhost:5004"
-
Right click under
src\Bigai.Play.Inventory.Service
-
Type the command
dotnet add package Bigai.Play.Common
, and press enter -
Type the command
dotnet add package Bigai.Play.Catalog.Contracts
, and press enter
-
Right click under
src\Bigai.Play.Inventory.Service
-
Type the command
dotnet add package Microsoft.Extensions.Http.Polly
, and press enter