Build and Run the application

The API generated consists of configuration to be ran locally or on a docker container.

Build and run locally

Move to the <PROJECT-NAME>/src/api folder and run the next commands in Command Prompt or Powershell

dotnet restore
dotnet clean
dotnet build
dotnet run --project xxAMIDOxx.xxSTACKSxx.API/xxAMIDOxx.xxSTACKSxx.API.csproj

Build and run in docker container

From the <PROJECT-NAME>/src/api folder, build a Docker image using e.g. the command below:

Build docker image
docker build -t dotnet-api .

This uses the Dockerfile in this folder to generate the Docker image.

After the creation of the Docker image, the Docker container can be run using the command below:

Run docker container
docker run -p 5000:80 --mount type=bind,source=/path/to/PROJECT-NAME/src/api/xxAMIDOxx.xxSTACKSxx.API/appsettings.json,target=/app/config/appsettings.json -e COSMOSDB_KEY=your-key dotnet-api:latest`

The COSMOSDB_KEY described in the command above has to be passed when running the container. Note that the appsettings.json value is mounted here for running locally, but not if the full project is deployed to Azure, where the build process will perform the substitution.

Verify that the application has started

Browse to http://localhost:5000/v1/menu. This should return a valid JSON response.

The application configuration uses Swagger/OAS3 to represent the API endpoints. The Swagger UI can be viewed by directing your browser to http://localhost:5000/swagger/index.html.