### Start Local Development Environment Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-compose-deployment-files Standard command to start the application using the base and override configuration files. ```console docker-compose -f docker-compose.yml -f docker-compose.override.yml ``` -------------------------------- ### Start Production or Remote Environment Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-compose-deployment-files Command to start the application using the production-specific configuration file. ```console docker-compose -f docker-compose.yml -f docker-compose.prod.yml ``` -------------------------------- ### Deploy application to local Docker host Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Mac-setup Start the entire solution using docker-compose. ```console docker-compose up ``` -------------------------------- ### Start Infrastructure Containers via PowerShell Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Unit-and-integration-testing Command to initialize the required infrastructure containers for functional testing. ```powershell docker-compose -f .\docker-compose-tests.yml -f .\docker-compose-tests.override.yml up ``` -------------------------------- ### Build and Start eShopOnContainers Locally Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-compose-deployment-files Commands to build and launch the application containers from the /src/ directory. ```powershell docker-compose build docker-compose up ``` -------------------------------- ### Install Node.js and npm in Dockerfile Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Frequent-errors Add these commands to your Dockerfile to install Node.js and npm. Ensure you are using the correct Node.js version for your project. ```bash RUN apt-get update RUN apt-get -y install curl gnupg RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - RUN apt-get -y install nodejs RUN npm install RUN npm -v ``` -------------------------------- ### Install NGINX Ingress Controller Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Install the NGINX Ingress controller using kubectl. This provides external access to services within the cluster. ```bash kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml ``` -------------------------------- ### Kubernetes Dashboard Token Output Example Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes An example of the output when retrieving the Kubernetes Dashboard bearer token. The 'token' field contains the value needed for login. ```console Name: admin-user-token-95nxr Namespace: kube-system Labels: Annotations: kubernetes.io/service-account.name=admin-user kubernetes.io/service-account.uid=aec979a2-7cb4-11e9-96aa-00155d013633 Type: kubernetes.io/service-account-token Data ==== ca.crt: 1025 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI...(800+ characters)...FkM_tAclj9o8T7ALdPZciaQ ``` -------------------------------- ### Define gRPC Service Interface Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Example of a service definition in a .proto file. ```protobuf // catalog.proto - Define gRPC service interface service Catalog { rpc GetItemById (CatalogItemRequest) returns (CatalogItemResponse) {} rpc GetItemsByIds (CatalogItemsRequest) returns (PaginatedItemsResponse) {} } ``` -------------------------------- ### Install Let's Encrypt staging issuer Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/AKS-TLS Deploys the Let's Encrypt staging issuer using Helm with the staging values configuration. ```bash helm install .\tls-support -f .\tls-support\values-staging.yaml -n tls-staging ``` -------------------------------- ### Launch ELK stack with Docker Compose Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/ELK-stack Use these commands in the root directory to build and start the ELK stack containers for local testing. ```sh docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.elk.yml build docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.elk.yml up ``` -------------------------------- ### Deploy eShopOnContainers with Docker Compose Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Commands to clone the repository, build container images, and start the application services locally. ```bash # Clone the repository git clone https://github.com/dotnet-architecture/eShopOnContainers.git cd eShopOnContainers/src # Build all Docker images docker-compose build # Deploy to local Docker host docker-compose up # Access the applications # Web Status: http://host.docker.internal:5107/ # Web MVC: http://host.docker.internal:5100/ # Web SPA: http://host.docker.internal:5104/ ``` -------------------------------- ### Start Kubernetes Proxy Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Execute the Kubernetes proxy command to enable access to the Kubernetes API server, which is required for accessing the dashboard. ```powershell kubectl proxy ``` -------------------------------- ### Install Chromium via NPM Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-configuration Installs the Chromium browser package for low-memory environments where standard browsers may consume too many resources. ```bash npm install --save chromium ``` -------------------------------- ### Update WebSPA Dockerfile for Node.js Installation Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Windows-setup Insert these commands into the WebSPA Dockerfile to install Node.js and related tools. This is necessary for the WebSPA project to build correctly. ```bash RUN apt-get update RUN apt-get -y install curl gnupg RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - RUN apt-get -y install nodejs RUN npm install RUN npm -v ``` -------------------------------- ### Install NGINX Ingress Controller Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Installs the NGINX Ingress controller using kubectl. This is required for external access to services within the Kubernetes cluster. ```powershell kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml ``` ```powershell kubectl apply -f .\local-cm.yaml ``` -------------------------------- ### CQRS Query Implementation with Dapper Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Provides an implementation for IOrderQueries using Dapper for direct SQL access. This example shows fetching order summaries for a user, optimized for read performance. ```csharp public class OrderQueries : IOrderQueries { private readonly string _connectionString; public async Task> GetOrdersFromUserAsync(Guid userId) { using (var connection = new SqlConnection(_connectionString)) { connection.Open(); return await connection.QueryAsync( @ ``` -------------------------------- ### Enable Azure Dev Spaces on AKS Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Azure-Dev-Spaces Configures an existing AKS cluster for use with Azure Dev Spaces. This command installs the Azure Dev Spaces CLI if it is not already present. ```console az aks use-dev-spaces -g your-aks-devspaces-resgrp -n YourAksDevSpacesCluster ``` -------------------------------- ### Kubernetes Health Check Probes Configuration Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Using-HealthChecks Example configuration for Kubernetes liveness and readiness probes within a Helm chart's `values.yaml` file. This defines the paths, timeouts, and intervals for health checks. ```yaml probes: liveness: path: /liveness initialDelaySeconds: 10 periodSeconds: 15 port: 80 readiness: path: /hc timeoutSeconds: 5 initialDelaySeconds: 90 periodSeconds: 60 port: 80 ``` -------------------------------- ### Azure CLI Script for AKS and ACR Setup Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deployment-With-GitHub-Actions This script automates the creation of an Azure Resource Group, Azure Container Registry (ACR), and Azure Kubernetes Service (AKS) cluster. It also configures ACR integration with AKS and sets up a service principal for push/pull roles. Run this script locally or in Azure Cloud Shell. ```bash export rg="" export acr="" export aks="" export spnName="" # see below if you have an existing SPN # create RG az group create -n $rg --location southcentralus # create ACR az acr create -g $rg -n $acr --sku Basic --admin-enabled true export acrId=$(az acr show -g $rg -n $acr --query "id" -o tsv) # assign push/pull role to SPN spnPassword=$(az ad sp create-for-rbac --name http://$spnName --scopes $acrId --role acrpush --query password --output tsv) spnId=$(az ad sp list --display-name http://$spnName --query [0].appId --output tsv) # Ref : https://github.com/Azure/azure-cli/issues/19179 # for an existing SPN # export spnId="" # az role assignment create --assignee $spnId --role acrpush --scope $acrId # create AKS cluster az aks create -g $rg -n $aks --node-count 1 --enable-addons monitoring,http_application_routing --enable-rbac --generate-ssh-keys --attach-acr $acr # set the k8s context locally az aks get-credentials -g $rg -n $aks # deploy nginx controller cd deploy/k8s/nginx-ingress kubectl apply -f mandatory.yaml kubectl apply -f local-cm.yaml kubectl apply -f local-svc.yaml # update nginx controller to allow large heaeders for login cd - cd deploy/k8s/helm kubectl apply -f aks-httpaddon-cfg.yaml kubectl delete pod $(kubectl get pod -l app=addon-http-application-routing-nginx-ingress -n kube-system -o jsonpath="{.items[0].metadata.name}") -n kube-system cd - # deploy all from public repos cd deploy/k8s/helm kubectl create ns eshop ./deploy-all.sh --dns aks --aks-name $aks --aks-rg $rg -t linux-latest # fix versions for apigwms (envoy) export domain="$(az aks show -n $aks -g $rg --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o tsv)" export dns="$aks.$domain" helm uninstall eshop-apigwms -n eshop helm install "eshop-apigwms" --namespace eshop --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=eshop --set inf.k8s.dns=$dns --set image.pullPolicy=Always apigwms helm uninstall eshop-apigwws -n eshop helm install "eshop-apigwws" --namespace eshop --set "ingress.hosts={$dns}" --values app.yaml --values inf.yaml --values ingress_values.yaml --set app.name=eshop --set inf.k8s.dns=$dns --set image.pullPolicy=Always apigwws ``` -------------------------------- ### Install cert-manager on AKS Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/AKS-TLS Executes the PowerShell script to install cert-manager version 0.11.0 on the specified AKS cluster. ```powershell .\enable-tls.ps1 -aksName eshopmesh -aksRg eshop-mesh ``` -------------------------------- ### Build Local Docker Images Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Navigate to the 'src' directory of your local eShop repository and run this command to build your Docker images. ```bash docker-compose build ``` -------------------------------- ### Configure gRPC Protobuf References Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt XML configuration for .csproj files to generate client or server stubs from proto files. ```xml ``` -------------------------------- ### Build eShopOnContainers Docker images Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Mac-setup Navigate to the source directory and build the application images using docker-compose. ```console cd eShopOnContainers\src docker-compose build ``` -------------------------------- ### Create repository directory Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Mac-setup Commands to create a local directory for git repositories. ```console cd md MyGitRepos cd MyGitRepos ``` -------------------------------- ### Create gRPC client Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/gRPC Initializing a gRPC channel and client stub for service communication. ```cs var channel = GrpcChannel.ForAddress(UrlOfService); var client = new Basket.BasketClient(channel); ``` -------------------------------- ### Deploy to Kubernetes with Helm Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Commands for setting up the NGINX Ingress controller and deploying the application to a local Kubernetes cluster. ```powershell # Install NGINX Ingress Controller kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/cloud/deploy.yaml # Configure proxy buffer size for identity service kubectl apply -f .\deploy\k8s\nginx-ingress\local-cm.yaml # Deploy using public DockerHub images (Windows) cd deploy/k8s/helm .\deploy-all.ps1 -imageTag linux-dev -useLocalk8s $true # Deploy using public DockerHub images (Mac) .\deploy-all-mac.ps1 -imageTag linux-dev -useLocalk8s $true # Deploy local images after building docker-compose build # Run from src directory first .\deploy-all.ps1 -imageTag linux-latest -useLocalk8s $true -imagePullPolicy Never # Check deployment status kubectl get deployment kubectl get ing # Delete deployments helm uninstall $(helm ls --filter eshop -q) ``` -------------------------------- ### Register gRPC service in Startup Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/gRPC Mapping the gRPC service within the ASP.NET Core endpoint configuration. ```cs app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); endpoints.MapControllers(); endpoints.MapGrpcService(); }); ``` -------------------------------- ### Check Azure Dev Spaces CLI Version Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Azure-Dev-Spaces Displays the currently installed version of the Azure Dev Spaces CLI and the associated API version. ```console Azure Dev Spaces CLI (Preview) 0.1.20190320.5 API v2.17 ``` -------------------------------- ### List Docker images Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Mac-setup Verify the creation of custom images after the build process completes. ```console docker images ``` -------------------------------- ### Get Kubernetes Dashboard Bearer Token (PowerShell) Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Retrieve the bearer token for logging into the Kubernetes Dashboard using PowerShell. This token is essential for authentication. ```powershell kubectl -n kubernetes-dashboard describe secret $(((kubectl -n kubernetes-dashboard get secret | Select-String 'admin-user') -split " ")[0]) ``` -------------------------------- ### Add HealthChecks Services Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Using-HealthChecks Configure health checks in the `ConfigureServices` method. This example adds a self-check and checks for dependent services like purchasing, marketing, and identity APIs. ```csharp services.AddHealthChecks() .AddCheck("self", () => HealthCheckResult.Healthy()) .AddUrlGroup(new Uri(configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" }) .AddUrlGroup(new Uri(configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" }) .AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); return services; ``` -------------------------------- ### Launch Windows Containers with Custom RabbitMQ Credentials Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Windows-containers Executes the deployment script with a flag to enable custom RabbitMQ login credentials. ```powershell .\cli-windows\start-windows-containers.ps1 -customEventBusLoginPassword $true ``` -------------------------------- ### Get Kubernetes Dashboard Bearer Token (Other Shell) Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Retrieve the bearer token for logging into the Kubernetes Dashboard using a shell environment other than PowerShell. This token is essential for authentication. ```bash kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') ``` -------------------------------- ### Get ILogger via Dependency Injection Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Serilog-and-Seq Obtain an ILogger instance through Dependency Injection in a class constructor. This is the standard way to access the logger for structured logging in .NET. ```csharp public class WorkerClass { private readonly ILogger _logger; public WorkerClass(ILogger logger) => _logger = logger; // If you have to use ILoggerFactory, change the constructor like this: public WorkerClass(ILoggerFactory loggerFactory) => _logger = loggerFactory.CreateLogger(); } ``` -------------------------------- ### Deploy Local Images (Windows) Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Use this PowerShell script to deploy eShop on AKS using your locally built and pushed images. Provide your ACR details and replace placeholders. ```powershell .\deploy-all.ps1 -externalDns aks -aksName -aksRg -imageTag linux-latest -registry .azurecr.io -dockerUser -dockerPassword -useMesh $false ``` -------------------------------- ### Configure Docker Compose Deployment Scenarios Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Various docker-compose commands for local development, production environments, Windows containers, and using pre-built images. ```bash # Local development (default) docker-compose -f docker-compose.yml -f docker-compose.override.yml up # Production/remote docker host deployment # Requires environment variables: # - ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP # - ESHOP_AZURE_STORAGE_CATALOG # - ESHOP_AZURE_STORAGE_MARKETING docker-compose -f docker-compose.yml -f docker-compose.prod.yml up # Windows containers deployment docker-compose -f docker-compose-windows.yml -f docker-compose.override.yml up # Pull pre-built images from DockerHub instead of building locally docker-compose -f docker-compose.nobuild.yml -f docker-compose.override.yml up ``` -------------------------------- ### Build Docker Images for Windows Containers Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Windows-containers Compile the .NET application code and build Docker images for Windows Containers. Ensure you are in the root folder of eShopOnContainers and use both docker-compose files when building. ```bash cd docker-compose -f docker-compose.yml -f docker-compose.windows.yml build ``` -------------------------------- ### Implement Health Checks in ASP.NET Core Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Configure health checks for microservices, including checks for self-health and external dependencies like API gateways. This setup is used for Kubernetes liveness and readiness probes. ```csharp // Configure health checks in Startup.ConfigureServices services.AddHealthChecks() .AddCheck("self", () => HealthCheckResult.Healthy()) .AddUrlGroup(new Uri(configuration["PurchaseUrlHC"]), name: "purchaseapigw-check", tags: new string[] { "purchaseapigw" }) .AddUrlGroup(new Uri(configuration["MarketingUrlHC"]), name: "marketingapigw-check", tags: new string[] { "marketingapigw" }) .AddUrlGroup(new Uri(configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" }); // Configure liveness endpoint (always returns OK if service is running) app.UseHealthChecks("/liveness", new HealthCheckOptions { Predicate = r => r.Name.Contains("self") }); // Configure readiness endpoint (checks all dependencies) app.UseHealthChecks("/hc", new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); ``` -------------------------------- ### Configure Protobuf generation in .csproj Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/gRPC Reference a .proto file in the project file to automatically generate gRPC client or server stubs during the build process. ```xml ``` -------------------------------- ### Helm Upgrade Task Configuration Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Azure-DevOps-pipelines Example configuration for a Helm upgrade task in an Azure DevOps release pipeline. This task deploys or upgrades a Helm chart to a Kubernetes cluster, specifying release name, chart path, and values. ```yaml arguments: namespace: "$(NAMESPACE)" chartType: "File Path" chartPath: "$(ARTIFACTSDIR)/helm/webstatus" releaseName: "$(RELEASE_NAME)" setValues: "inf.k8s.dns=$(inf.k8s.dns),image.repository=$(image.repository),image.tag=$(image.tag)" installIfNotFound: "true" recreatePods: "true" waitFor: "true" ``` -------------------------------- ### Deploy Local Images (Mac) Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Use this shell script to deploy eShop on AKS using your locally built and pushed images. Provide your ACR details and replace placeholders. ```bash .\deploy-all-mac.ps1 -externalDns aks -aksName -aksRg -imageTag linux-latest -registry .azurecr.io -dockerUser -dockerPassword -useMesh $false ``` -------------------------------- ### Configure Serilog Logger Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Serilog-and-Seq Set up the Serilog logger in Program.cs, ensuring logging services are available early. This configuration includes minimum level, enrichment properties, and sinks for Console and Seq. It also allows reading configuration from appsettings.json. ```csharp private static Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) { var seqServerUrl = configuration["Serilog:SeqServerUrl"]; return new LoggerConfiguration() .MinimumLevel.Verbose() .Enrich.WithProperty("ApplicationContext", AppName) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.Seq(string.IsNullOrWhiteSpace(seqServerUrl) ? "http://seq" : seqServerUrl) .ReadFrom.Configuration(configuration) .CreateLogger(); } ``` -------------------------------- ### Configure Marketing API PicBaseUrl Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Updates the marketing configuration to point to an external storage URL. ```yaml marketing__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/ ``` ```yaml marketing__PicBaseUrl: http:/// ``` -------------------------------- ### Configure AddAzureKeyVault with MSI in ASP.NET Core Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Azure-Key-Vault Uses AzureServiceTokenProvider and KeyVaultClient to authenticate with Key Vault via MSI. Requires the Microsoft.Azure.Services.AppAuthentication and Microsoft.Azure.KeyVault NuGet packages. ```csharp public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() .ConfigureAppConfiguration((context,builder)=> { var azureServiceTokenProvider = new AzureServiceTokenProvider(); var keyVaultClient = new KeyVaultClient( new KeyVaultClient.AuthenticationCallback( azureServiceTokenProvider.KeyVaultTokenCallback)); builder.AddAzureKeyVault("https://[mykeyvault].vault.azure.net/", keyVaultClient, new DefaultKeyVaultSecretManager()); }).Build(); ``` -------------------------------- ### Structured Logging Usage with ILogger Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Demonstrates injecting and using ILogger for structured logging within a class. It emphasizes using named parameters for structured data instead of string interpolation for better log analysis. ```csharp public class WorkerClass { private readonly ILogger _logger; public WorkerClass(ILogger logger) => _logger = logger; public void ProcessEvent(IntegrationEvent @event) { // Use structured logging with named parameters (NOT string interpolation) _logger.LogInformation( "----- Publishing integration event: {IntegrationEventId} from {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); } } ``` -------------------------------- ### Create Kubernetes Dashboard Admin User Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Create a sample admin user and role binding for accessing the Kubernetes Dashboard. This is a necessary step after deploying the dashboard. ```powershell kubectl apply -f dashboard-adminuser.yaml ``` -------------------------------- ### Implement CreateOrderCommandHandler Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Simplified-CQRS-and-DDD Handles the execution of CreateOrderCommand. Orchestrates order creation, item addition, and saving via repository. ```csharp public class CreateOrderCommandHandler : IRequestHandler { private readonly IOrderRepository _orderRepository; private readonly IIdentityParser _userIdentityParser; private readonly ILogger _logger; public CreateOrderCommandHandler( IOrderRepository orderRepository, IIdentityParser userIdentityParser, ILogger logger) { _orderRepository = orderRepository; _userIdentityParser = userIdentityParser; _logger = logger; } public async Task Handle(CreateOrderCommand message, CancellationToken cancellationToken) { var user = _userIdentityParser.Parse(message.UserIdentity); var order = new Order(user.Id, user.Name, message.UserDescription); message.OrderItems.ToList().ForEach(item => order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Quantity)); await _orderRepository.AddAsync(order); await _orderRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken); return true; } } ``` -------------------------------- ### Open Solution for Visual Studio Debugging Source: https://context7.com/dotnet-architecture/eshoponcontainers/llms.txt Identifies the solution file for debugging server-side microservices in Visual Studio 2022. ```bash eShopOnContainers-ServicesAndWebApps.sln ``` -------------------------------- ### Tag Local Docker Images Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Tag your locally built eShop images with your ACR login server. This prepares them for pushing to your private registry. Replace placeholders accordingly. ```bash docker tag eshop/mobileshoppingagg:linux-latest .azurecr.io/eshop/mobileshoppingagg:linux-lates docker tag eshop/ordering.signalrhub:linux-latest .azurecr.io/eshop/ordering.signalrhub:linux-lates ``` -------------------------------- ### Application Component URLs Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-compose-deployment-files Default URLs for accessing the various components of the application after startup. ```text Web Status : http://host.docker.internal:5107/ Web MVC : http://host.docker.internal:5100/ Web SPA : http://host.docker.internal:5104/ ``` -------------------------------- ### Deploy eShopOnContainers with Local Images (Windows) Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Local-Kubernetes Deploys eShopOnContainers using locally built images on Windows. This sets imagePullPolicy to 'Never', ensuring only local images are used. Ensure you are in the 'deploy/k8s/helm' directory. ```powershell .\deploy-all.ps1 -imageTag linux-latest -useLocalk8s $true -imagePullPolicy Never ``` -------------------------------- ### Deploy Windows Containers via Docker Compose Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Windows-containers Deploys containers using multiple configuration files while ensuring the required volume specification environment variable is set. ```console set ESHOP_OCELOT_VOLUME_SPEC=C:\app\configuration docker-compose -f docker-compose.yml -f docker-compose.override.yml -f -f docker-compose.windows.yml -f docker-compose.override.windows.yml up ``` -------------------------------- ### Apply Local NGINX Configuration Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Apply a local configuration file for the NGINX Ingress controller, which sets the proxy-buffer size required by the identity service. ```bash kubectl apply -f .\local-cm.yaml ``` -------------------------------- ### Verify Ingress Resources Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Lists all ingress resources to confirm public service exposure. ```console eshop-apigwmm eshop...aksapp.io 80 4d eshop-apigwms eshop...aksapp.io 80 4d eshop-apigwwm eshop...aksapp.io 80 4d eshop-apigwws eshop...aksapp.io 80 4d eshop-identity-api eshop...aksapp.io 80 4d eshop-webhooks-api eshop...aksapp.io 80 4d eshop-webhooks-web eshop...aksapp.io 80 4d eshop-webmvc eshop...aksapp.io 80 4d eshop-webspa eshop...aksapp.io 80 4d eshop-webstatus eshop...aksapp.io 80 4d ``` -------------------------------- ### Implement generated gRPC service Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/gRPC Implementation of the abstract base class generated from the proto file. ```cs public class CatalogService : CatalogBase { public CatalogService() { } public override async Task GetItemById(CatalogItemRequest request, ServerCallContext context) { // Code } public override async Task GetItemsByIds(CatalogItemsRequest request, ServerCallContext context) { // Code } } ``` -------------------------------- ### GitHub Actions Deployment Workflow for catalog-api Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deployment-With-GitHub-Actions A YAML configuration for deploying the catalog-api microservice to AKS. Note that the 'if: false' condition must be updated to enable execution. ```yml name: Deploy catalog-api on: workflow_dispatch: repository_dispatch: types: - deploy workflow_run: workflows: ["catalog-api"] branches: [dev] types: [completed] env: CHART: catalog-api NAMESPACE: eshop CHART_ROOT: deploy/k8s/helm jobs: deploy-to-k8s: #if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' || github.event.workflow_run.conclusion == 'success' }} if: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: azure/login@v1 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - uses: azure/aks-set-context@v1 name: Set AKS context with: creds: '${{ secrets.AZURE_CREDENTIALS }}' cluster-name: ${{ secrets.CLUSTER_NAME }} resource-group: ${{ secrets.RESOURCE_GROUP }} - name: Set branch name as env variable run: | currentbranch=$(echo ${GITHUB_REF##*/}) echo "running on $currentbranch" echo "BRANCH=$currentbranch" >> $GITHUB_ENV shell: bash - name: Deploy CHART run: | ./deploy-CHART.sh -c ${{ env.CHART }} --dns aks --aks-name ${{ secrets.CLUSTER_NAME }} --aks-rg ${{ secrets.RESOURCE_GROUP }} -r ${{ secrets.REGISTRY_HOST }} -t $TAG --NAMESPACE ${{ env.NAMESPACE }} --acr-connected env: TAG: ${{ env.BRANCH }} working-directory: ${{ env.CHART_ROOT }} ``` -------------------------------- ### Configure Catalog API PicBaseUrl Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Deploy-to-Azure-Kubernetes-Service-(AKS) Updates the catalog configuration to point to an external storage URL. ```yaml catalog__PicBaseUrl: http://{{ $webshoppingapigw }}/api/v1/c/catalog/items/[0]/pic/ ``` ```yaml catalog__PicBaseUrl: http:/// ``` -------------------------------- ### Deploy with Production Docker Compose Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Docker-host Use this command to deploy eShopOnContainers using both the base and production docker-compose files. This ensures that production-specific configurations, including external IP settings, are applied. ```bash docker-compose -f docker-compose.yml -f docker-compose.prod.yml up ``` -------------------------------- ### Configure Azure Storage Account Source: https://github.com/dotnet-architecture/eshoponcontainers/wiki/Using-Azure-resources Set the storage account endpoint URL in the .env file, ensuring a trailing slash is included. ```text ESHOP_AZURE_STORAGE_CATALOG=https://yourcatalogstorageaccountservice.blob.core.windows.net/yourcontainername/ ```