### Install and Run React SPA Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Installs dependencies and starts the React development server for the UI. Access the application at http://localhost:3000. ```bash cd src/UIs/reactjs npm install && npm run dev ``` -------------------------------- ### EF Core Tooling and Migrations Setup Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Install EF Core tooling and add an initial migration for the AdsDbContext. ```bash # 1. Install EF Core tooling and create migrations dotnet tool install --global dotnet-ef --version="8.0" cd src/Monolith/ClassifiedAds.Migrator dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb ``` -------------------------------- ### Install npm packages and serve Angular app Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Navigate to the Angular project directory and run these commands to install dependencies and start the development server. ```bash npm install ng serve ``` -------------------------------- ### Install and Run Vue SPA Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Installs dependencies and starts the Vue development server for the UI. Access the application at http://localhost:8080. ```bash cd src/UIs/vuejs npm install && npm run dev ``` -------------------------------- ### Install Microservices with Helm Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Install the microservices using Helm, list installed releases, upgrade an existing release, and uninstall a release. ```bash helm install myrelease .helm/microservices helm list helm upgrade myrelease .helm/microservices helm uninstall myrelease ``` -------------------------------- ### Running Bootstrap Documentation Locally Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/IdentityServers/Duende/ClassifiedAds.IdentityServer/wwwroot/lib/bootstrap/README.md Commands to set up and run the Bootstrap documentation site locally. Ensure you have completed the tooling setup and installed Node.js dependencies. ```bash bundle install npm install npm start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/vuejs/README.md Run this command to install all the necessary packages for the project. ```sh npm install ``` -------------------------------- ### Install and Deploy to Azure Static Web App Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/reactjs/README.md Install the Azure Static Web Apps CLI globally and deploy the application to Azure. Ensure the build output is in the `./dist` folder. ```bash npm install -g @azure/static-web-apps-cli swa deploy ./dist --app-name react --env production ``` -------------------------------- ### Install npm packages and run React dev server Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Navigate to the React project directory and execute these commands to install dependencies and launch the development server. ```bash npm install npm run dev ``` -------------------------------- ### Start Services with Docker Compose Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/docker build.txt Starts all defined services using Docker Compose, applying configurations from both 'docker-compose.yml' and 'docker-compose.volumes.yml'. ```bash docker-compose -f docker-compose.yml -f docker-compose.volumes.yml up ``` -------------------------------- ### Install EF Core .NET CLI Tools Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/IdentityServers/Duende/ClassifiedAds.Migrator/dotnet-cli.txt Installs or updates the Entity Framework Core .NET CLI tools globally. Ensure you have the .NET SDK installed. ```bash dotnet tool install --global dotnet-ef --version="8.0" ``` -------------------------------- ### Application Running Instructions Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Instructions for running the application via Visual Studio or CLI, including Docker Compose and Angular SPA setup. ```bash # 2. Run from Visual Studio or CLI # Web API: https://localhost:44312 (Swagger UI at root /) # Web MVC: https://localhost:44364 # Identity Server: https://localhost:44367 # Blazor: https://localhost:44331 # 3. Docker Compose (Monolith) cd src/Monolith docker compose build docker compose up # Web MVC: http://host.docker.internal:9003 # Identity Server: http://host.docker.internal:9000 # 4. Angular SPA cd src/UIs/angular npm install && ng serve # http://localhost:4200 ``` -------------------------------- ### Install Sonar Scanner Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Commands to install the Sonar Scanner for .NET, list global tools, and check the Java version. Ensure Java is installed and accessible in your PATH. ```bash dotnet tool install --global dotnet-sonarscanner dotnet tool list --global java --version ``` -------------------------------- ### Install EF Core CLI Source: https://github.com/phongnguyend/practical.cleanarchitecture/wiki/How-to-Run Installs the Entity Framework Core command-line interface tool globally. Ensure you are using version 3.1 as specified. ```bash dotnet tool install --global dotnet-ef --version="3.1" ``` -------------------------------- ### Start SQL Server Topology with Debezium Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/tools/debezium/README.md Use this command to start the Debezium topology for SQL Server using Docker Compose. Ensure the DEBEZIUM_VERSION environment variable is set. ```shell # Start the topology as defined in https://debezium.io/documentation/reference/stable/tutorial.html export DEBEZIUM_VERSION=2.0 docker-compose -f docker-compose-sqlserver.yaml up ``` -------------------------------- ### Docker Compose Build and Up Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/docker build.txt Builds all services defined in a docker-compose.yml file and then starts them. Can also build specific services. ```bash docker-compose build docker-compose up ``` ```bash docker-compose build blazorserverside ``` ```bash docker-compose up webmvc docker-compose up blazorserverside ``` -------------------------------- ### Build and Run Locally with Aspire Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Builds the solution and runs the application using the .NET Aspire host. Assumes Aspire SDK is installed. ```bash dotnet build dotnet run --project ClassifiedAds.AspireAppHost ``` -------------------------------- ### Install Helm Chart Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Installs the modular monolith application using Helm. Replace 'myrelease' with your desired release name. ```bash helm install myrelease .helm/modularmonolith helm list ``` -------------------------------- ### Install and Configure SQL Server Distributed Cache Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Installs the dotnet-sql-cache tool and creates a SQL Server table for distributed caching. ```bash dotnet tool install --global dotnet-sql-cache --version="5.0" dotnet sql-cache create "Server=127.0.0.1;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#" dbo CacheEntries ``` -------------------------------- ### Start Development Server Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/vuejs/README.md Use this command to compile and hot-reload the Vue.js application for development. ```sh npm run dev ``` -------------------------------- ### Install Bicep CLI Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/bicep/README.md Install or update the Azure Bicep CLI to the latest version. ```bash az bicep install ``` -------------------------------- ### Install and Manage OctoPack Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Commands to install, check version, update, uninstall, and install a specific version of the OctoPack CLI tool. ```bash dotnet tool install Octopus.DotNet.Cli --global --version 4.39.1 dotnet octo --version dotnet tool update Octopus.DotNet.Cli --global dotnet tool uninstall Octopus.DotNet.Cli --global dotnet tool install Octopus.DotNet.Cli --global --version ``` -------------------------------- ### Install Azure Static Web Apps CLI Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/angular/README.md Command to install the Azure Static Web Apps CLI globally using npm. This tool is required for deploying the application. ```bash npm install -g @azure/static-web-apps-cli ``` -------------------------------- ### Install jQuery for Node.js Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/IdentityServers/Duende/ClassifiedAds.IdentityServer/wwwroot/lib/jquery/README.md To use jQuery in a Node.js environment, first install it using npm. This command installs the package locally. ```sh npm install jquery ``` -------------------------------- ### Build and run Docker containers Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Navigate to the Monolith directory and execute these commands to build the Docker images and start the containers defined in the docker-compose file. ```bash docker compose build docker compose up ``` -------------------------------- ### Run Next.js Development Server Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/nextjs/README.md Use these commands to start the development server for your Next.js application. Open http://localhost:3000 in your browser to view the result. The page auto-updates as you edit files. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Docker Version Information Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/docker build.txt Displays the installed Docker version. ```bash docker --version docker version ``` -------------------------------- ### Manage Docker Containers Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/docker build.txt Lists running and all containers, and provides commands to start, stop, and remove containers. ```bash docker ps docker ps -a docker start docker stop docker rm xxx ``` -------------------------------- ### Apply Kubernetes Manifests Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Applies Kubernetes deployment and service configurations from the .k8s directory. Use 'kubectl get all' to verify resources. ```bash kubectl apply -f .k8s kubectl get all kubectl get services kubectl get pods ``` -------------------------------- ### Check Bicep Version Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/bicep/README.md Verify the installed version of the Azure Bicep CLI. ```bash az bicep version ``` -------------------------------- ### Create Roles Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_IdentityDbContext_GenerateExpectedScript.verified.txt Sets up the Roles table, including columns for role name, concurrency stamp, row version, and audit timestamps. Uses sequential GUIDs for primary keys. ```sql CREATE TABLE [Roles] ( [Id] uniqueidentifier NOT NULL DEFAULT (newsequentialid()), [Name] nvarchar(max) NULL, [NormalizedName] nvarchar(max) NULL, [ConcurrencyStamp] nvarchar(max) NULL, [RowVersion] rowversion NULL, [CreatedDateTime] datetimeoffset NOT NULL, [UpdatedDateTime] datetimeoffset NULL, CONSTRAINT [PK_Roles] PRIMARY KEY ([Id]) ); ``` -------------------------------- ### Dispatch Commands and Queries from Controller Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Usage example of the Dispatcher in a controller to send commands and queries. The Dispatcher handles routing to the appropriate handlers and decorators. ```csharp // --- Controller usage --- var products = await _dispatcher.DispatchAsync(new GetProductsQuery()); await _dispatcher.DispatchAsync(new AddUpdateProductCommand { Product = product }); ``` -------------------------------- ### SonarQube Build and Scan Process Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/README.md Initiate a SonarQube scan with specified version, host URL, organization, project key, and token. Then build the solution and end the scan. ```bash dotnet sonarscanner begin /v:"1.0.0" /d:sonar.host.url="https://sonarcloud.io" /o:"phongnguyend" /k:"Monolith" /d:sonar.login="" dotnet build ClassifiedAds.Monolith.slnx dotnet sonarscanner end /d:sonar.login="" ``` -------------------------------- ### Build and Scan with SonarQube Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Initiates a SonarQube scan, builds the solution, and completes the scan. Ensure you replace `` with your actual SonarQube token. ```bash dotnet sonarscanner begin /v:"1.0.0" /d:sonar.host.url="https://sonarcloud.io" /o:"phongnguyend" /k:"Microservices" /d:sonar.login="" dotnet build ClassifiedAds.Microservices.slnx dotnet sonarscanner end /d:sonar.login="" ``` -------------------------------- ### Run Microservices Locally with Aspire Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Build the project and run the Aspire host for local development. Access the Aspire Dashboard via the provided URL. ```bash dotnet build dotnet run --project AspireAppHost ``` -------------------------------- ### Build Projects for Packaging Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Commands to restore dependencies, build the solution, and publish individual projects for packaging. Ensure the solution file is correctly referenced. ```bash dotnet restore ClassifiedAds.ModularMonolith.slnx dotnet build -p:Version=1.0.0.1 -c Release dotnet publish -p:Version=1.0.0.1 -c Release ../IdentityServers/OpenIddict/ClassifiedAds.IdentityServer/ClassifiedAds.IdentityServer.csproj -o ./publish/ClassifiedAds.IdentityServer dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Background/ClassifiedAds.Background.csproj -o ./publish/ClassifiedAds.Background dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Migrator/ClassifiedAds.Migrator.csproj -o ./publish/ClassifiedAds.Migrator dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.WebAPI/ClassifiedAds.WebAPI.csproj -o ./publish/ClassifiedAds.WebAPI ``` -------------------------------- ### Create Azure Static Web Apps Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Use these commands to create free-tier Static Web Apps for different frontend frameworks. Ensure the resource group exists. ```bash az staticwebapp create --resource-group "ClassifiedAds_DEV" \ --name angular \ --location "eastasia" \ --sku Free \ --tags "Environment=Development" "Project=ClassifiedAds" "Department=SD" ``` ```bash az staticwebapp create --resource-group "ClassifiedAds_DEV" \ --name react \ --location "eastasia" \ --sku Free \ --tags "Environment=Development" "Project=ClassifiedAds" "Department=SD" ``` ```bash az staticwebapp create --resource-group "ClassifiedAds_DEV" \ --name vue \ --location "eastasia" \ --sku Free \ --tags "Environment=Development" "Project=ClassifiedAds" "Department=SD" ``` -------------------------------- ### Build and Scan with SonarQube Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Commands to initiate a SonarQube scan, build the solution, and end the scan. Replace placeholders for version, SonarCloud URL, organization, project key, and token. ```bash dotnet sonarscanner begin /v:"1.0.0" /d:sonar.host.url="https://sonarcloud.io" /o:"phongnguyend" /k:"ModularMonolith" /d:sonar.login="" dotnet build ClassifiedAds.ModularMonolith.slnx dotnet sonarscanner end /d:sonar.login="" ``` -------------------------------- ### Tag and Push Docker Image for Product API Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/docker build.txt Tags the 'classifiedads.services.product.api' Docker image with the repository path 'phongnguyend/classifiedads.services.product.api' and pushes it to the registry. ```bash docker tag classifiedads.services.product.api phongnguyend/classifiedads.services.product.api ``` ```bash docker push phongnguyend/classifiedads.services.product.api ``` -------------------------------- ### Helm Chart Management Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/README.md Commands for managing Helm releases, including installation, listing, upgrading, and uninstallation of the monolith chart. ```bash helm install myrelease .helm/monolith ``` ```bash helm list ``` ```bash helm upgrade myrelease .helm/monolith ``` ```bash helm uninstall myrelease ``` -------------------------------- ### Create Configuration Entries Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_GenerateExpectedScript.verified.txt Sets up the ConfigurationEntries table for storing application configuration settings. Includes key, value, description, sensitivity flag, and timestamps. ```sql CREATE TABLE [ConfigurationEntries] ( [Id] uniqueidentifier NOT NULL DEFAULT (newsequentialid()), [Key] nvarchar(max) NULL, [Value] nvarchar(max) NULL, [Description] nvarchar(max) NULL, [IsSensitive] bit NOT NULL, [RowVersion] rowversion NULL, [CreatedDateTime] datetimeoffset NOT NULL, [UpdatedDateTime] datetimeoffset NULL, CONSTRAINT [PK_ConfigurationEntries] PRIMARY KEY ([Id]) ); ``` -------------------------------- ### Build Projects with Specific Version Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/README.md Restore dependencies, build projects in Release configuration with a specified version, and publish individual project outputs. ```bash dotnet restore ClassifiedAds.Monolith.slnx dotnet build -p:Version=1.0.0.1 -c Release dotnet publish -p:Version=1.0.0.1 -c Release ../IdentityServers/OpenIddict/ClassifiedAds.IdentityServer/ClassifiedAds.IdentityServer.csproj -o ./publish/ClassifiedAds.IdentityServer dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Background/ClassifiedAds.Background.csproj -o ./publish/ClassifiedAds.Background dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.Migrator/ClassifiedAds.Migrator.csproj -o ./publish/ClassifiedAds.Migrator dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.WebAPI/ClassifiedAds.WebAPI.csproj -o ./publish/ClassifiedAds.WebAPI dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.BlazorServerSide/ClassifiedAds.BlazorServerSide.csproj -o ./publish/ClassifiedAds.BlazorServerSide dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.BlazorWebAssembly/ClassifiedAds.BlazorWebAssembly.csproj -o ./publish/ClassifiedAds.BlazorWebAssembly dotnet publish -p:Version=1.0.0.1 -c Release ./ClassifiedAds.WebMVC/ClassifiedAds.WebMVC.csproj -o ./publish/ClassifiedAds.WebMVC ``` -------------------------------- ### Add Application Insights Extension Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Installs the Application Insights extension for Azure CLI. This must be done before creating Application Insights components. ```bash az extension add -n application-insights ``` -------------------------------- ### Configure Kafka Message Broker Source: https://github.com/phongnguyend/practical.cleanarchitecture/wiki/How-to-Run Sets up the message broker to use Kafka. Requires bootstrap servers and topic names for file events. ```json "MessageBroker": { "Provider": "Kafka", "Kafka": { "BootstrapServers": "localhost:9092", "Topic_FileUploaded": "classifiedadds_fileuploaded", "Topic_FileDeleted": "classifiedadds_filedeleted" }, } ``` -------------------------------- ### Insert Data into Users Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_IdentityDbContext_GenerateExpectedScript.verified.txt An example of how to insert data into the Users table, enabling identity insertion for specific columns. This is typically used during migration scripts. ```sql IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'AccessFailedCount', N'Auth0UserId', N'AzureAdB2CUserId', N'ConcurrencyStamp', N'CreatedDateTime', N'Email', N'EmailConfirmed', N'LockoutEnabled', N'LockoutEnd', N'NormalizedEmail', N'NormalizedUserName', N'PasswordHash', N'PhoneNumber', N'PhoneNumberConfirmed', N'SecurityStamp', N'TwoFactorEnabled', N'UpdatedDateTime', N'UserName') AND [object_id] = OBJECT_ID(N'[Users]')) SET IDENTITY_INSERT [Users] ON; INSERT INTO [Users] ([Id], [AccessFailedCount], [Auth0UserId], [AzureAdB2CUserId], [ConcurrencyStamp], [CreatedDateTime], [Email], [EmailConfirmed], [LockoutEnabled], [LockoutEnd], [NormalizedEmail], [NormalizedUserName], [PasswordHash], [PhoneNumber], [PhoneNumberConfirmed], [SecurityStamp], [TwoFactorEnabled], [UpdatedDateTime], [UserName]) ``` -------------------------------- ### Configure Security Headers in Startup.cs Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/docs/Security/README.md This C# code demonstrates how to integrate the custom `UseSecurityHeaders` extension method into the `Configure` method of your `Startup.cs` class. It should be placed after other middleware like `UseHsts` but before `UseMvc` or other routing middleware. ```csharp public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseSecurityHeaders(); .... app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } ``` -------------------------------- ### Register Application Services and Message Handlers Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Register application services, message handlers, and interceptors in the DI container. This setup scans assemblies for handlers and wraps them with specified decorators. ```csharp services.AddApplicationServices() // ICrudService<>, IUserService, IProductService .AddMessageHandlers() // scans assembly, registers all ICommandHandler / IQueryHandler .ConfigureInterceptors(); // wraps handlers with AuditLog / DatabaseRetry decorators ``` -------------------------------- ### Add Product Database Migration Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.Product/ClassifiedAds.Services.Product.Api/PowerShell.txt Use this command to create a new migration for the ProductDbContext. Specify a name for the migration and an output directory. ```powershell Add-Migration -Context ProductDbContext Init -OutputDir Migrations/ProductDb ``` -------------------------------- ### Generate EF Core DbContext Script Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/IdentityServers/OpenIddict/ClassifiedAds.Migrator/dotnet-cli.txt Generates a SQL script for the entire database schema based on the current DbContext. Useful for initial setup or full schema generation. ```bash dotnet ef dbcontext script --context OpenIddictDbContext ``` -------------------------------- ### Build Microservices Projects Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Commands to restore dependencies, build, and publish individual microservice projects. Specify the desired version and build configuration (e.g., Release). ```bash dotnet restore ClassifiedAds.Microservices.slnx dotnet build -p:Version=1.0.0.1 -c Release dotnet publish -p:Version=1.0.0.1 -c Release ../IdentityServers/OpenIddict/ClassifiedAds.IdentityServer/ClassifiedAds.IdentityServer.csproj -o ./publish/ClassifiedAds.IdentityServer dotnet publish -p:Version=1.0.0.1 -c Release ./Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI/ClassifiedAds.Gateways.WebAPI.csproj -o ./publish/ClassifiedAds.Gateways.WebAPI dotnet publish -p:Version=1.0.0.1 -c Release ./Services.AuditLog/ClassifiedAds.Services.AuditLog.Api/ClassifiedAds.Services.AuditLog.Api.csproj -o ./publish/ClassifiedAds.Services.AuditLog.Api dotnet publish -p:Version=1.0.0.1 -c Release ./Services.AuditLog/ClassifiedAds.Services.AuditLog.Grpc/ClassifiedAds.Services.AuditLog.Grpc.csproj -o ./publish/ClassifiedAds.Services.AuditLog.Grpc dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Configuration/ClassifiedAds.Services.Configuration.Api/ClassifiedAds.Services.Configuration.Api.csproj -o ./publish/ClassifiedAds.Services.Configuration.Api dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Identity/ClassifiedAds.Services.Identity.Api/ClassifiedAds.Services.Identity.Api.csproj -o ./publish/ClassifiedAds.Services.Identity.Api dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Identity/ClassifiedAds.Services.Identity.Grpc/ClassifiedAds.Services.Identity.Grpc.csproj -o ./publish/ClassifiedAds.Services.Identity.Grpc dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Notification/ClassifiedAds.Services.Notification.Api/ClassifiedAds.Services.Notification.Api.csproj -o ./publish/ClassifiedAds.Services.Notification.Api dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Notification/ClassifiedAds.Services.Notification.Background/ClassifiedAds.Services.Notification.Background.csproj -o ./publish/ClassifiedAds.Services.Notification.Background dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Notification/ClassifiedAds.Services.Notification.Grpc/ClassifiedAds.Services.Notification.Grpc.csproj -o ./publish/ClassifiedAds.Services.Notification.Grpc dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Product/ClassifiedAds.Services.Product.Api/ClassifiedAds.Services.Product.Api.csproj -o ./publish/ClassifiedAds.Services.Product.Api dotnet publish -p:Version=1.0.0.1 -c Release ./Services.Storage/ClassifiedAds.Services.Storage.Api/ClassifiedAds.Services.Storage.Api.csproj -o ./publish/ClassifiedAds.Services.Storage.Api ``` -------------------------------- ### Intercepting Async Method Calls with DynamicProxy Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/ClassifiedAds.Infrastructure/Interceptors/Reference.md Example demonstrating how to intercept an async method that returns a Task using DynamicProxy. Ensure the interceptor correctly handles the asynchronous nature of the method. ```csharp public class InterceptAsyncMethod { public async Task DoSomethingAsync() { await Task.Delay(1000); } } public class AsyncInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { // Check if the method is async and returns Task if (invocation.Method.ReturnType == typeof(Task) && invocation.Method.IsAsync) { // Invoke the async method and await its completion invocation.Proceed(); var task = invocation.ReturnValue as Task; if (task != null) { // You can perform actions before or after awaiting the task // For example, logging or error handling task.Wait(); // Or await task if in an async context } } else { // Handle non-async methods or other return types invocation.Proceed(); } } } ``` -------------------------------- ### Tag and Push Docker Image for Gateways WebAPI Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/docker build.txt Tags the 'classifiedads.gateways.webapi' Docker image with the repository path 'phongnguyend/classifiedads.gateways.webapi' and then pushes it to the registry. ```bash docker tag classifiedads.gateways.webapi phongnguyend/classifiedads.gateways.webapi ``` ```bash docker push phongnguyend/classifiedads.gateways.webapi ``` -------------------------------- ### Run Notification Service Background Container Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.Notification/docker build.txt Starts the Notification Background service container in detached mode. It maps host port 8081 to container port 80 and assigns a specific name. ```bash docker run -d -p 8081:80 --name classifiedads.services.notification.background classifiedads.services.notification.background ``` -------------------------------- ### Build Product Service API Docker Image Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.Product/docker build.txt Builds a Docker image for the Product Service API using a specified Dockerfile. Use this command to create the image before running the container. ```bash docker build -f "ClassifiedAds.Services.Product.Api\Dockerfile" -t classifiedads.services.product.api ../ ``` -------------------------------- ### Configure SQL Database Connection String Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Retrieves the ADO.NET connection string for a SQL database and substitutes placeholder credentials. The output is echoed to the console. ```bash connectionString=$(az sql db show-connection-string -s classifiedadsdev -n classifiedadsdevdb -c ado.net --out tsv) connectionString=${connectionString//classifiedads} connectionString=${connectionString//'sqladmin123!@#'} echo $connectionString ``` -------------------------------- ### Run Audit Log gRPC Docker Container Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.AuditLog/docker build.txt Runs the ClassifiedAds.Services.AuditLog.Grpc Docker container in detached mode and maps host port 8081 to container port 80. This command starts the gRPC service. ```bash docker run -d -p 8081:80 --name classifiedads.services.auditlog.grpc classifiedads.services.auditlog.grpc ``` -------------------------------- ### Tag Docker Images for Microservices Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Tag local Docker images with the repository path for pushing to a registry. This prepares images for deployment. ```bash docker tag classifiedads.gateways.webapi phongnguyend/classifiedads.gateways.webapi docker tag classifiedads.services.auditlog.api phongnguyend/classifiedads.services.auditlog.api docker tag classifiedads.services.auditlog.grpc phongnguyend/classifiedads.services.auditlog.grpc docker tag classifiedads.services.configuration.api phongnguyend/classifiedads.services.configuration.api docker tag classifiedads.services.identity.api phongnguyend/classifiedads.services.identity.api docker tag classifiedads.services.identity.authserver phongnguyend/classifiedads.services.identity.authserver docker tag classifiedads.services.identity.grpc phongnguyend/classifiedads.services.identity.grpc docker tag classifiedads.services.notification.api phongnguyend/classifiedads.services.notification.api docker tag classifiedads.services.notification.background phongnguyend/classifiedads.services.notification.background docker tag classifiedads.services.notification.grpc phongnguyend/classifiedads.services.notification.grpc docker tag classifiedads.services.product.api phongnguyend/classifiedads.services.product.api docker tag classifiedads.services.storage.api phongnguyend/classifiedads.services.storage.api ``` -------------------------------- ### Run Audit Log API Docker Container Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.AuditLog/docker build.txt Runs the ClassifiedAds.Services.AuditLog.Api Docker container in detached mode and maps host port 8080 to container port 80. This command starts the API service. ```bash docker run -d -p 8080:80 --name classifiedads.services.auditlog.api classifiedads.services.auditlog.api ``` -------------------------------- ### Create Azure Kubernetes Service (AKS) Cluster Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Creates an Azure Kubernetes Service cluster with a specified node count and location. It also includes commands to log in to Azure and get AKS credentials. ```bash az aks create --resource-group "ClassifiedAds_DEV" \ --name ClassifiedAdsCluster \ --location "southeastasia" \ --node-count 3 az login az aks get-credentials --resource-group ClassifiedAds_DEV --name ClassifiedAdsCluster --overwrite-existing ``` -------------------------------- ### Configure Storage for WebMVC Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Retrieves the primary storage connection string and configures the WebMVC to use Azure storage. ```bash storageConnectionString=$(az storage account show-connection-string \ --resource-group ClassifiedAds_DEV \ --name classifiedadsdev \ --key primary \ --query connectionString \ --out tsv) echo $storageConnectionString az webapp config appsettings set \ --resource-group ClassifiedAds_DEV \ --name webmvc-classifiedads \ --settings "Storage__Provider=Azure" \ "Storage__Azure_ConnectionString=$storageConnectionString" ``` -------------------------------- ### Intercepting Generic Task<> Async Methods with DynamicProxy Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/IdentityServers/OpenIddict/ClassifiedAds.Infrastructure/Interceptors/Reference.md Provides an example of intercepting an async method that returns a generic Task type (e.g., Task) using DynamicProxy. This requires careful handling of the returned Task. ```csharp public class InterceptGenericTaskMethod { public async Task GetDataAsync() { await Task.Delay(100); return "Some Data"; } } public class GenericTaskMethodInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine("Before generic async method call."); invocation.Proceed(); var task = (Task)invocation.ReturnValue; task.ContinueWith(t => { if (t.IsCompletedSuccessfully) { Console.WriteLine($"Async method returned: {t.Result}"); } else { Console.WriteLine("Async method failed."); } }); Console.WriteLine("After generic async method call setup."); } } // Usage: // var proxyGenerator = new ProxyGenerator(); // var interceptedInstance = proxyGenerator.CreateClassProxy( // new GenericTaskMethodInterceptor()); // var result = await interceptedInstance.GetDataAsync(); ``` -------------------------------- ### Create Event Hubs Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Creates individual Event Hubs within a namespace. Configurable with message retention and partition count. ```bash az eventhubs eventhub create --resource-group "ClassifiedAds_DEV" \ --namespace-name "classifiedadshubsdev" \ --name classifiedadds_fileuploaded \ --message-retention 1 \ --partition-count 2 az eventhubs eventhub create --resource-group "ClassifiedAds_DEV" \ --namespace-name "classifiedadshubsdev" \ --name classifiedadds_filedeleted \ --message-retention 1 \ --partition-count 2 ``` -------------------------------- ### Run Product Service API Docker Container Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.Product/docker build.txt Runs the Product Service API Docker container in detached mode, mapping host port 8080 to container port 80. This command starts the service after the image has been built. ```bash docker run -d -p 8080:80 --name classifiedads.services.product.api classifiedads.services.product.api ``` -------------------------------- ### Create Azure Container App Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Creates a new Azure Container App. This command deploys a specified container image, configures ingress, and allocates resources. Ensure the image name and target port are correct. ```bash az containerapp create \ --name classifiedads-webmvc \ --resource-group ClassifiedAds_DEV \ --environment ClassifiedAds-DEV \ --image phongnguyend/classifiedads.webmvc \ --target-port 443 \ --ingress external \ --cpu 0.5 --memory 1.0Gi ``` -------------------------------- ### Create Users Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_IdentityDbContext_GenerateExpectedScript.verified.txt Defines the Users table schema, including authentication details, contact information, lockout status, audit timestamps, and external user IDs (Auth0, AzureAdB2C). Uses sequential GUIDs for primary keys. ```sql CREATE TABLE [Users] ( [Id] uniqueidentifier NOT NULL DEFAULT (newsequentialid()), [UserName] nvarchar(max) NULL, [NormalizedUserName] nvarchar(max) NULL, [Email] nvarchar(max) NULL, [NormalizedEmail] nvarchar(max) NULL, [EmailConfirmed] bit NOT NULL, [PasswordHash] nvarchar(max) NULL, [PhoneNumber] nvarchar(max) NULL, [PhoneNumberConfirmed] bit NOT NULL, [TwoFactorEnabled] bit NOT NULL, [ConcurrencyStamp] nvarchar(max) NULL, [SecurityStamp] nvarchar(max) NULL, [LockoutEnabled] bit NOT NULL, [LockoutEnd] datetimeoffset NULL, [AccessFailedCount] int NOT NULL, [Auth0UserId] nvarchar(max) NULL, [AzureAdB2CUserId] nvarchar(max) NULL, [RowVersion] rowversion NULL, [CreatedDateTime] datetimeoffset NOT NULL, [UpdatedDateTime] datetimeoffset NULL, CONSTRAINT [PK_Users] PRIMARY KEY ([Id]) ); ``` -------------------------------- ### Build Docker Image for Product API Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/docker build.txt Builds a Docker image for the Product API service. The image is tagged as 'classifiedads.services.product.api' using its Dockerfile. ```bash docker build -f "Services.Product\ClassifiedAds.Services.Product.Api\Dockerfile" -t classifiedads.services.product.api . ``` -------------------------------- ### SonarQube Scanner Configuration (Windows) Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/bff/reactjs/README.md Commands to set the SONAR_TOKEN environment variable and run the SonarQube scanner on Windows. Replace `` with your actual SonarQube token. ```bash echo %SONAR_TOKEN% setx SONAR_TOKEN set SONAR_TOKEN= sonar-scanner.bat -D"sonar.organization=phongnguyend" -D"sonar.projectKey=UIs_React" -D"sonar.projectName=UIs React" -D"sonar.projectVersion=1.0.0.0" -D"sonar.sources=." -D"sonar.host.url=https://sonarcloud.io" ``` -------------------------------- ### Record Initial Migration Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_ProductDbContext_GenerateExpectedScript.verified.txt Records the 'Init' migration with version '20231215102250_Init' and product version '9.0.1' in the migration history table. ```sql INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion]) VALUES (N'20231215102250_Init', N'9.0.1'); ``` -------------------------------- ### Build for Production Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/vuejs/README.md This command checks types, compiles, and minifies the Vue.js application for production deployment. ```sh npm run build ``` -------------------------------- ### Deploy to Azure Static Web App Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/vuejs/README.md Deploy the built application to Azure Static Web Apps. Replace './dist' with your build output directory if different. ```bash swa deploy ./dist --app-name vue --env production ``` -------------------------------- ### Configure Both SQL Server and Azure Key Vault Configuration Sources Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Enable both SQL Server and Azure Key Vault as configuration sources. Ensure all necessary connection details and vault names are provided. ```json "ConfigurationSources": { "SqlServer": { "IsEnabled": true, "ConnectionString": "Server=127.0.0.1;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, "AzureKeyVault": { "IsEnabled": true, "VaultName": "https://xxx.vault.azure.net/" } }, ``` -------------------------------- ### CREATE TABLE Products Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_GenerateExpectedScript.verified.txt Defines the schema for the Products table, including columns for product ID, code, name, description, and timestamps. Requires IDENTITY_INSERT to be enabled for inserts. ```sql IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'Code', N'CreatedDateTime', N'Description', N'Name', N'UpdatedDateTime') AND [object_id] = OBJECT_ID(N'[Products]')) SET IDENTITY_INSERT [Products] ON; INSERT INTO [Products] ([Id], [Code], [CreatedDateTime], [Description], [Name], [UpdatedDateTime]) ``` -------------------------------- ### Configure Local File System Storage Source: https://context7.com/phongnguyend/practical.cleanarchitecture/llms.txt Select 'Local' provider in appsettings.json for local file system storage. Specify the 'Path' for file storage and a 'TempFolderPath'. ```json { "Storage": { "Provider": "Local", "Local": { "Path": "C:\\classifiedads\\files" }, "MasterEncryptionKey": "", "TempFolderPath": "C:\\classifiedads\\temp" } } ``` -------------------------------- ### Create Products Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_ProductDbContext_GenerateExpectedScript.verified.txt Defines the Products table schema, including columns for Id, Code, Name, Description, RowVersion, and timestamps. Uses default sequential ID generation. ```sql CREATE TABLE [Products] ( [Id] uniqueidentifier NOT NULL DEFAULT (newsequentialid()), [Code] nvarchar(max) NULL, [Name] nvarchar(max) NULL, [Description] nvarchar(max) NULL, [RowVersion] rowversion NULL, [CreatedDateTime] datetimeoffset NOT NULL, [UpdatedDateTime] datetimeoffset NULL, CONSTRAINT [PK_Products] PRIMARY KEY ([Id]) ); ``` -------------------------------- ### Configure SQL Server Configuration Source Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Enable SQL Server as a configuration source by setting IsEnabled to true. Ensure the ConnectionString and SqlQuery are correctly configured. ```json "ConfigurationSources": { "SqlServer": { "IsEnabled": false, "ConnectionString": "Server=127.0.0.1;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, "AzureKeyVault": { "IsEnabled": false, "VaultName": "https://xxx.vault.azure.net/" } }, ``` ```json "ConfigurationSources": { "SqlServer": { "IsEnabled": true, "ConnectionString": "Server=127.0.0.1;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, }, ``` -------------------------------- ### Configure Storage for WebAPI Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Retrieves the primary storage connection string and configures the WebAPI to use Azure storage. ```bash storageConnectionString=$(az storage account show-connection-string \ --resource-group ClassifiedAds_DEV \ --name classifiedadsdev \ --key primary \ --query connectionString \ --out tsv) echo $storageConnectionString az webapp config appsettings set \ --resource-group ClassifiedAds_DEV \ --name webapi-classifiedads \ --settings "Storage__Provider=Azure" \ "Storage__Azure_ConnectionString=$storageConnectionString" ``` -------------------------------- ### Configure Local Storage Provider Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Set the Storage Provider to 'Local' and specify the local directory path. ```json "Storage": { "Provider": "Local", }, ``` ```json "Storage": { "Provider": "Local", "Local": { "Path": "E:\\files" }, }, ``` -------------------------------- ### EF Core Migrations with dotnet CLI Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Monolith/README.md Commands to add a new database migration and apply it to the database using the dotnet CLI. Requires navigating to the Migrator project. ```bash dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb ``` ```bash dotnet ef database update --context AdsDbContext ``` -------------------------------- ### Pack Microservices Projects into Nuget Packages Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/README.md Commands to pack the published microservice projects into Nuget packages using OctoPack. Ensure the version, output folder, and base path are correctly specified for each package. ```bash dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.IdentityServer --basePath=./publish/ClassifiedAds.IdentityServer dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Gateways.WebAPI --basePath=./publish/ClassifiedAds.Gateways.WebAPI dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.AuditLog.Api --basePath=./publish/ClassifiedAds.Services.AuditLog.Api dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.AuditLog.Grpc --basePath=./publish/ClassifiedAds.Services.AuditLog.Grpc dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Configuration.Api --basePath=./publish/ClassifiedAds.Services.Configuration.Api dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Identity.Api --basePath=./publish/ClassifiedAds.Services.Identity.Api dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Identity.Grpc --basePath=./publish/ClassifiedAds.Services.Identity.Grpc dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Notification.Api --basePath=./publish/ClassifiedAds.Services.Notification.Api dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Notification.Background --basePath=./publish/ClassifiedAds.Services.Notification.Background dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Notification.Grpc --basePath=./publish/ClassifiedAds.Services.Notification.Grpc dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Product.Api --basePath=./publish/ClassifiedAds.Services.Product.Api dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Services.Storage.Api --basePath=./publish/ClassifiedAds.Services.Storage.Api ``` -------------------------------- ### Pack Projects using OctoPack Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/README.md Commands to pack individual projects into Nuget packages using OctoPack. Specify the version, output folder, overwrite behavior, package ID, and base path for each project. ```bash dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.IdentityServer --basePath=./publish/ClassifiedAds.IdentityServer dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Background --basePath=./publish/ClassifiedAds.Background dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.Migrator --basePath=./publish/ClassifiedAds.Migrator dotnet octo pack --version=1.0.0.1 --outFolder=./publish --overwrite --id=ClassifiedAds.WebAPI --basePath=./publish/ClassifiedAds.WebAPI ``` -------------------------------- ### Create Azure Container Apps Environment Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/deployments/Azure/README.md Creates a new Azure Container Apps environment. Specify the desired name, resource group, and location. ```bash az containerapp env create \ --name ClassifiedAds-DEV \ --resource-group ClassifiedAds_DEV \ --location southeastasia ``` -------------------------------- ### Add New Migration to ConfigurationDbContext Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/Microservices/Services.Configuration/ClassifiedAds.Services.Configuration.Api/PowerShell.txt Use this command to create a new migration for the ConfigurationDbContext. Specify a name for the migration and an output directory. ```powershell Add-Migration -Context ConfigurationDbContext Init -OutputDir Migrations/ConfigurationDb ``` -------------------------------- ### Create ConfigurationEntries Table Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/ModularMonolith/ClassifiedAds.Migrator.Tests/MigrationTests.MigrationTests_ConfigurationDbContext_GenerateExpectedScript.verified.txt This SQL script defines the `ConfigurationEntries` table, which stores application configuration settings. It includes columns for key, value, description, sensitivity, and audit timestamps. The `RowVersion` column is used for optimistic concurrency. ```sql BEGIN TRANSACTION; CREATE TABLE [ConfigurationEntries] ( [Id] uniqueidentifier NOT NULL DEFAULT (newsequentialid()), [Key] nvarchar(max) NULL, [Value] nvarchar(max) NULL, [Description] nvarchar(max) NULL, [IsSensitive] bit NOT NULL, [RowVersion] rowversion NULL, [CreatedDateTime] datetimeoffset NOT NULL, [UpdatedDateTime] datetimeoffset NULL, CONSTRAINT [PK_ConfigurationEntries] PRIMARY KEY ([Id]) ); IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'CreatedDateTime', N'Description', N'IsSensitive', N'Key', N'UpdatedDateTime', N'Value') AND [object_id] = OBJECT_ID(N'[ConfigurationEntries]')) SET IDENTITY_INSERT [ConfigurationEntries] ON; INSERT INTO [ConfigurationEntries] ([Id], [CreatedDateTime], [Description], [IsSensitive], [Key], [UpdatedDateTime], [Value]) VALUES ('8a051aa5-bcd1-ea11-b098-ac728981bd15', '0001-01-01T00:00:00.0000000+00:00', NULL, CAST(0 AS bit), N'SecurityHeaders:Test-Read-From-SqlServer', NULL, N'this-is-read-from-sqlserver'); IF EXISTS (SELECT * FROM [sys].[identity_columns] WHERE [name] IN (N'Id', N'CreatedDateTime', N'Description', N'IsSensitive', N'Key', N'UpdatedDateTime', N'Value') AND [object_id] = OBJECT_ID(N'[ConfigurationEntries]')) SET IDENTITY_INSERT [ConfigurationEntries] OFF; ``` -------------------------------- ### Enable All Logging Options Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/README.md Configures logging to use multiple destinations including file, Elasticsearch, and Windows Event Log. ```js "Logging": { "LogLevel": { "Default": "Warning" }, "File": { "MinimumLogEventLevel": "Information" }, "Elasticsearch": { "IsEnabled": true, "Host": "http://localhost:9200", "IndexFormat": "classifiedads", "MinimumLogEventLevel": "Information" }, "EventLog": { "IsEnabled": true, "LogName": "Application", "SourceName": "ClassifiedAds.WebAPI" } }, ``` -------------------------------- ### Input Fields for Configuration Entry Source: https://github.com/phongnguyend/practical.cleanarchitecture/blob/master/src/UIs/angular/src/app/settings/configuration-entry-list.component.html Provides input fields for entering the key, value, description, and sensitive flag for a configuration entry. ```html Key Enter a key Value Enter a value Description Enter a description Sensitive ```