diff --git a/README.md b/README.md index afdcc72..315c4ad 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,16 @@ When looking at the telemetry tree, it looks as following: Before you can run this, you need to: -1. Run solution with Docker Compose -2. Get bacon by calling the API - GET http://localhost:789/api/v1/bacon -3. Create order to eat bacon asynchronously by calling the API - POST http://localhost:787/api/v1/market +1. Create an Application Insights resource in your Azure Subscription +2. Create an Azure Service Bus namespace resource in your Azure Subscription +3. Create a queue called `orders` in the Azure Service Bus namespace +4. Create a `docker-compose.override.yml` file and set the Application Insights instrumentation key and Service Bus connectionstring +5. Run solution with Docker Compose by running `docker compose up` from the folder where the `docker-compose.yml` file is located +6. Get bacon by calling the API - GET http://localhost:789/api/v1/bacon +7. Create order to eat bacon asynchronously by calling the API - POST http://localhost:787/api/v1/market + +> You can use a tool like Postman to perform API requests, or you can use the Swagger UI page which is available at `localhost:787/api/docs` for the Market API and at `localhost:789/api/docs` for the Bacon API. + ```json { "amount": 2 diff --git a/src/Arcus.API.Bacon/Controllers/BaconController.cs b/src/Arcus.API.Bacon/Controllers/BaconController.cs index 91ca185..8007b0e 100644 --- a/src/Arcus.API.Bacon/Controllers/BaconController.cs +++ b/src/Arcus.API.Bacon/Controllers/BaconController.cs @@ -37,9 +37,7 @@ public BaconController(IBaconRepository baconRepository, ILoggerProvides an overview of various bacon flavors. /// Bacon is served! /// Uh-oh! Things went wrong - [HttpGet(Name = "Bacon_Get")] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)] + [HttpGet(Name = "Bacon_Get")] [SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] [SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] public async Task Get() diff --git a/src/Arcus.API.Bacon/Controllers/HealthController.cs b/src/Arcus.API.Bacon/Controllers/HealthController.cs index c2a3d86..c5e5f22 100644 --- a/src/Arcus.API.Bacon/Controllers/HealthController.cs +++ b/src/Arcus.API.Bacon/Controllers/HealthController.cs @@ -33,9 +33,7 @@ public HealthController(HealthCheckService healthCheckService) /// Provides an indication about the health of the API. /// API is healthy /// API is unhealthy or in degraded state - [HttpGet(Name = "Health_Get")] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)] + [HttpGet(Name = "Health_Get")] [SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] [SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] public async Task Get() diff --git a/src/Arcus.API.Bacon/Dockerfile b/src/Arcus.API.Bacon/Dockerfile index fd8f5d7..40bd2f2 100644 --- a/src/Arcus.API.Bacon/Dockerfile +++ b/src/Arcus.API.Bacon/Dockerfile @@ -4,14 +4,14 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build WORKDIR /src -COPY ["Arcus.API.Bacon.csproj", ""] -COPY . . -WORKDIR "/src/." -RUN dotnet build "Arcus.API.Bacon.csproj" -c Release -o /app +COPY ["./Arcus.API.Bacon/Arcus.API.Bacon.csproj", ""] +COPY . ./ + +WORKDIR "/src" FROM build AS publish -RUN dotnet publish "Arcus.API.Bacon.csproj" -c Release -o /app +RUN dotnet publish "./Arcus.API.Bacon/Arcus.API.Bacon.csproj" -c Release -o /app FROM base AS final WORKDIR /app diff --git a/src/Arcus.API.Bacon/Program.cs b/src/Arcus.API.Bacon/Program.cs index aa02c5a..39d4b97 100644 --- a/src/Arcus.API.Bacon/Program.cs +++ b/src/Arcus.API.Bacon/Program.cs @@ -46,8 +46,7 @@ private static IConfiguration CreateConfiguration(string[] args) { IConfigurationRoot configuration = new ConfigurationBuilder() - .AddCommandLine(args) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddCommandLine(args) .AddEnvironmentVariables() .Build(); @@ -62,12 +61,7 @@ private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration conf .ConfigureAppConfiguration(configBuilder => configBuilder.AddConfiguration(configuration)) .ConfigureSecretStore((config, stores) => { -#if DEBUG stores.AddConfiguration(config); -#endif - - //#error Please provide a valid secret provider, for example Azure Key Vault: https://security.arcus-azure.net/features/secrets/consume-from-key-vault - stores.AddAzureKeyVaultWithManagedServiceIdentity("https://your-keyvault.vault.azure.net/"); }) .UseSerilog(DefineLoggerConfiguration) .ConfigureWebHostDefaults(webBuilder => diff --git a/src/Arcus.API.Market/Controllers/HealthController.cs b/src/Arcus.API.Market/Controllers/HealthController.cs index ec5c4f1..1fd742f 100644 --- a/src/Arcus.API.Market/Controllers/HealthController.cs +++ b/src/Arcus.API.Market/Controllers/HealthController.cs @@ -33,9 +33,7 @@ public HealthController(HealthCheckService healthCheckService) /// Provides an indication about the health of the API. /// API is healthy /// API is unhealthy or in degraded state - [HttpGet(Name = "Health_Get")] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)] + [HttpGet(Name = "Health_Get")] [SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] [SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] public async Task Get() diff --git a/src/Arcus.API.Market/Controllers/MarketController.cs b/src/Arcus.API.Market/Controllers/MarketController.cs index e5ac1c0..e9bbf2b 100644 --- a/src/Arcus.API.Market/Controllers/MarketController.cs +++ b/src/Arcus.API.Market/Controllers/MarketController.cs @@ -44,8 +44,6 @@ public MarketController(IOrderRepository orderRepository, IBaconService baconSer /// Order is created /// Uh-oh! Things went wrong [HttpPost(Name = "Market_CreateOrder")] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status201Created)] - [ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)] [SwaggerResponseHeader(201, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")] [SwaggerResponseHeader(201, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")] public async Task CreateOrder([FromBody] OrderRequest orderRequest) diff --git a/src/Arcus.API.Market/Dockerfile b/src/Arcus.API.Market/Dockerfile index e3a2943..4e0ea71 100644 --- a/src/Arcus.API.Market/Dockerfile +++ b/src/Arcus.API.Market/Dockerfile @@ -4,16 +4,14 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build WORKDIR /src -COPY ["Arcus.API.Salads.csproj", ""] - +COPY ["./Arcus.API.Market/Arcus.API.Market.csproj", ""] COPY . . -WORKDIR "/src/." -RUN dotnet build "Arcus.API.Salads.csproj" -c Release -o /app FROM build AS publish -RUN dotnet publish "Arcus.API.Salads.csproj" -c Release -o /app +RUN dotnet publish "./Arcus.API.Market/Arcus.API.Market.csproj" -c Release -o /app FROM base AS final WORKDIR /app COPY --from=publish /app . -ENTRYPOINT ["dotnet", "Arcus.API.Salads.dll"] +ENTRYPOINT ["dotnet", "Arcus.API.Market.dll"] + \ No newline at end of file diff --git a/src/Arcus.API.Market/Program.cs b/src/Arcus.API.Market/Program.cs index fb9fd8b..164ee08 100644 --- a/src/Arcus.API.Market/Program.cs +++ b/src/Arcus.API.Market/Program.cs @@ -46,8 +46,7 @@ private static IConfiguration CreateConfiguration(string[] args) { IConfigurationRoot configuration = new ConfigurationBuilder() - .AddCommandLine(args) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddCommandLine(args) .AddEnvironmentVariables() .Build(); @@ -62,12 +61,7 @@ private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration conf .ConfigureAppConfiguration(configBuilder => configBuilder.AddConfiguration(configuration)) .ConfigureSecretStore((config, stores) => { -#if DEBUG stores.AddConfiguration(config); -#endif - - //#error Please provide a valid secret provider, for example Azure Key Vault: https://security.arcus-azure.net/features/secrets/consume-from-key-vault - stores.AddAzureKeyVaultWithManagedServiceIdentity("https://your-keyvault.vault.azure.net/"); }) .UseSerilog(DefineLoggerConfiguration) .ConfigureWebHostDefaults(webBuilder => diff --git a/src/Arcus.Shared/SerilogFactory.cs b/src/Arcus.Shared/SerilogFactory.cs index 9af3fc9..f8d6afa 100644 --- a/src/Arcus.Shared/SerilogFactory.cs +++ b/src/Arcus.Shared/SerilogFactory.cs @@ -9,7 +9,7 @@ namespace Arcus.Shared { public class SerilogFactory { - private const string ApplicationInsightsInstrumentationKeyName = "ApplicationInsights_InstrumentationKey"; + private const string ApplicationInsightsInstrumentationKeyName = "APPINSIGHTS_INSTRUMENTATIONKEY"; public static void ConfigureSerilog(string componentName, LoggerConfiguration loggerConfiguration, IConfiguration configuration, IServiceProvider serviceProvider, bool useHttpCorrelation = true) { diff --git a/src/Arcus.Workers.Orders/Dockerfile b/src/Arcus.Workers.Orders/Dockerfile index 4f74fd6..5196c80 100644 --- a/src/Arcus.Workers.Orders/Dockerfile +++ b/src/Arcus.Workers.Orders/Dockerfile @@ -4,14 +4,11 @@ EXPOSE 80 FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build WORKDIR /src -COPY ["Arcus.Workers.Orders.csproj", ""] - +COPY ["./Arcus.Workers.Orders/Arcus.Workers.Orders.csproj", ""] COPY . . -WORKDIR "/src/." -RUN dotnet build "Arcus.Workers.Orders.csproj" -c Release -o /app FROM build AS publish -RUN dotnet publish "Arcus.Workers.Orders.csproj" -c Release -o /app +RUN dotnet publish "./Arcus.Workers.Orders/Arcus.Workers.Orders.csproj" -c Release -o /app FROM base AS final WORKDIR /app