Domain-Driven Design Path | Pluralsight
Database
-
Update Connection Strings:
Project Configuration File Configuration Key ClassifiedAds.Migrator appsettings.json ConnectionStrings:ClassifiedAds ClassifiedAds.BackgroundServer appsettings.json ConnectionStrings:ClassifiedAds ClassifiedAds.IdentityServer appsettings.json ConnectionStrings:ClassifiedAds ClassifiedAds.WebAPI appsettings.json ConnectionStrings:ClassifiedAds ClassifiedAds.WebMVC appsettings.json ConnectionStrings:ClassifiedAds -
Run Migration:
- Option 1: Using dotnet cli:
- Install dotnet-ef cli:
dotnet tool install --global dotnet-ef --version="3.1"
- Navigate to ClassifiedAds.Migrator and run these commands:
dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb dotnet ef migrations add Init --context ConfigurationDbContext -o Migrations/ConfigurationDb dotnet ef migrations add Init --context PersistedGrantDbContext -o Migrations/PersistedGrantDb dotnet ef migrations add Init --context MiniProfilerDbContext -o Migrations/MiniProfilerDb dotnet ef database update --context AdsDbContext dotnet ef database update --context ConfigurationDbContext dotnet ef database update --context PersistedGrantDbContext dotnet ef database update --context MiniProfilerDbContext
- Install dotnet-ef cli:
- Option 2: Using Package Manager Console:
- Set ClassifiedAds.Migrator as StartUp Project
- Open Package Manager Console, select ClassifiedAds.Migrator as Default Project
- Run these commands:
Add-Migration -Context AdsDbContext Init -OutputDir Migrations/AdsDb Add-Migration -Context ConfigurationDbContext Init -OutputDir Migrations/ConfigurationDb Add-Migration -Context PersistedGrantDbContext Init -OutputDir Migrations/PersistedGrantDb Add-Migration -Context MiniProfilerDbContext Init -OutputDir Migrations/MiniProfilerDb Update-Database -Context AdsDbContext Update-Database -Context ConfigurationDbContext Update-Database -Context PersistedGrantDbContext Update-Database -Context MiniProfilerDbContext
- Option 1: Using dotnet cli:
Additional Configuration Sources
-
Open ClassifiedAds.WebMVC/appsettings.json and jump to ConfigurationSources section.
"ConfigurationSources": { "SqlServer": { "IsEnabled": false, "ConnectionString": "Server=.;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#;MultipleActiveResultSets=true", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, "AzureKeyVault": { "IsEnabled": false, "VaultName": "SD1597" } },
-
Get from Sql Server database:
"ConfigurationSources": { "SqlServer": { "IsEnabled": true, "ConnectionString": "Server=.;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#;MultipleActiveResultSets=true", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, },
-
Get from Azure Key Vault:
"ConfigurationSources": { "AzureKeyVault": { "IsEnabled": true, "VaultName": "SD1597" } },
-
Use Both:
"ConfigurationSources": { "SqlServer": { "IsEnabled": true, "ConnectionString": "Server=.;Database=ClassifiedAds;User Id=sa;Password=sqladmin123!@#;MultipleActiveResultSets=true", "SqlQuery": "select [Key], [Value] from ConfigurationEntries" }, "AzureKeyVault": { "IsEnabled": true, "VaultName": "SD1597" } },
Storage
-
Open ClassifiedAds.WebMVC/appsettings.json and jump to Storage section.
"Storage": { "Provider": "Local", },
-
Use Local Files:
"Storage": { "Provider": "Local", "Local": { "Path": "E:\\files" }, },
-
Use Azure Blob:
"Storage": { "Provider": "Azure", "Azure": { "ConnectionString": "xxx", "Container": "classifiedadds" }, },
-
Use Amazon S3:
"Storage": { "Provider": "Amazon", "Amazon": { "AccessKeyID": "xxx", "SecretAccessKey": "xxx", "BucketName": "classifiedadds", "RegionEndpoint": "ap-southeast-1" } },
Message Broker
-
Open ClassifiedAds.WebMVC/appsettings.json and ClassifiedAds.BackgroundServer/appsettings.json and jump to MessageBroker section.
"MessageBroker": { "Provider": "RabbitMQ", }
-
Use RabbitMQ
"MessageBroker": { "Provider": "RabbitMQ", "RabbitMQ": { "HostName": "localhost", "UserName": "guest", "Password": "guest", "ExchangeName": "amq.direct", "RoutingKey_FileUploaded": "classifiedadds_fileuploaded", "RoutingKey_FileDeleted": "classifiedadds_filedeleted", "QueueName_FileUploaded": "classifiedadds_fileuploaded", "QueueName_FileDeleted": "classifiedadds_filedeleted" }, }
-
Use Kafka:
"MessageBroker": { "Provider": "Kafka", "Kafka": { "BootstrapServers": "localhost:9092", "Topic_FileUploaded": "classifiedadds_fileuploaded", "Topic_FileDeleted": "classifiedadds_filedeleted" }, }
-
Use Azure Queue Storage:
"MessageBroker": { "Provider": "AzureQueue", "AzureQueue": { "ConnectionString": "xxx", "QueueName_FileUploaded": "classifiedadds-fileuploaded", "QueueName_FileDeleted": "classifiedadds-filedeleted" }, }
-
Use Azure Service Bus:
"MessageBroker": { "Provider": "AzureServiceBus", "AzureServiceBus": { "ConnectionString": "xxx", "QueueName_FileUploaded": "classifiedadds_fileuploaded", "QueueName_FileDeleted": "classifiedadds_filedeleted" } }
Logging
- Open and jump to Logging section of below files:
- ClassifiedAds.WebAPI/appsettings.json
- ClassifiedAds.WebMVC/appsettings.json
- ClassifiedAds.IdentityServer/appsettings.json
- ClassifiedAds.BackgroundServer/appsettings.json
"Logging": { "LogLevel": { "Default": "Warning" }, "File": { "MinimumLogEventLevel": "Information" }, "Elasticsearch": { "IsEnabled": false, "Host": "http://localhost:9200", "IndexFormat": "classifiedads", "MinimumLogEventLevel": "Information" }, "EventLog": { "IsEnabled": false, "LogName": "Application", "SourceName": "ClassifiedAds.WebAPI" } },
- Write to Local file (./logs/log.txt). Always enabled.
"Logging": { "File": { "MinimumLogEventLevel": "Information" }, },
- Write to Elasticsearch:
"Logging": { "Elasticsearch": { "IsEnabled": true, "Host": "http://localhost:9200", "IndexFormat": "classifiedads", "MinimumLogEventLevel": "Information" }, },
- Write to Windows Event Log (Windows only):
"Logging": { "EventLog": { "IsEnabled": true, "LogName": "Application", "SourceName": "ClassifiedAds.WebAPI" } },
- Enable all options:
"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" } },
Interceptors
- Open and jump to Interceptors section of below files:
- ClassifiedAds.WebAPI/appsettings.json
- ClassifiedAds.WebMVC/appsettings.json
- ClassifiedAds.IdentityServer/appsettings.json
- ClassifiedAds.BackgroundServer/appsettings.json
"Interceptors": { "LoggingInterceptor": true, "ErrorCatchingInterceptor": false },
Security Headers
- Open ClassifiedAds.WebAPI/appsettings.json and jump to SecurityHeaders section:
"SecurityHeaders": { "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0" },
- Open ClassifiedAds.WebMVC/appsettings.json and jump to SecurityHeaders section:
"SecurityHeaders": { "Content-Security-Policy": "form-action 'self'; frame-ancestors 'none'", "Feature-Policy": "camera 'none'", "Referrer-Policy": "strict-origin-when-cross-origin", "X-Content-Type-Options": "nosniff", "X-Frame-Options": "DENY", "X-XSS-Protection": "1; mode=block", "Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0" },
Cross-Origin Resource Sharing (CORS)
- Open ClassifiedAds.WebAPI/appsettings.json and jump to CORS section:
"CORS": { "AllowAnyOrigin": false, "AllowedOrigins": [ "http://localhost:4200", "http://localhost:3000", "http://localhost:8080" ] },
- Open ClassifiedAds.NotificationServer/appsettings.json and jump to CORS section:
"CORS": { "AllowedOrigins": [ "https://localhost:44364", "http://host.docker.internal:9003" ] }
-
Web MVC Home Page: https://localhost:44364/
-
Navigate to Health Checks UI https://localhost:44364/healthchecks-ui#/healthchecks and make sure everything is green.
-
Login on Identity Server:
- Option 1: Use default created account:
- User Name: [email protected]
- Password: v*7Un8b4rcN@<-RN
- Option 2: Register new account at https://localhost:44367/Account/Register
- Option 1: Use default created account:
-
Open Blazor Home Page at: https://localhost:44331
-
Angular:
-
Navigate to folder: ClassifiedAds.UIs/angular/
npm install ng serve
-
Go to http://localhost:4200/
-
-
React:
-
Navigate to folder: ClassifiedAds.UIs/reactjs/
npm install npm run start
-
Go to http://localhost:3000/
-
-
Vue:
-
Navigate to folder: ClassifiedAds.UIs/vuejs/
npm install npm run serve
-
Go to http://localhost:8080/
-
-
Before Login, go to Identity Server https://localhost:44367/Client to make sure application clients have been registered:
-
Add Migrations if you haven't done on previous steps:
- Install dotnet-ef cli:
dotnet tool install --global dotnet-ef --version="3.1"
- Navigate to ClassifiedAds.Migrator and run these commands:
dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb dotnet ef migrations add Init --context ConfigurationDbContext -o Migrations/ConfigurationDb dotnet ef migrations add Init --context PersistedGrantDbContext -o Migrations/PersistedGrantDb dotnet ef migrations add Init --context MiniProfilerDbContext -o Migrations/MiniProfilerDb
- Install dotnet-ef cli:
-
Navigate to ClassifiedAds.Monolith and run:
docker-compose build docker-compose up
-
Open Web MVC Home Page at: http://host.docker.internal:9003
-
Navigate to Health Checks UI http://host.docker.internal:9003/healthchecks-ui#/healthchecks and make sure everything is green.
-
Login on Identity Server:
- Use default created account: [email protected] / v*7Un8b4rcN@<-RN
- Register new account at http://host.docker.internal:9000/Account/Register
-
Open Blazor Home Page at: http://host.docker.internal:9008
Project | Launch URL | Docker Container URL | Docker Container URL |
---|---|---|---|
BackgroundServer | https://localhost:44318 | http://localhost:9004 | http://host.docker.internal:9004 |
Blazor | https://localhost:44331 | http://localhost:9008 | http://host.docker.internal:9008 |
IdentityServer | https://localhost:44367 | http://localhost:9000 | http://host.docker.internal:9000 |
NotificationServer | https://localhost:44390 | http://localhost:9001 | http://host.docker.internal:9001 |
WebAPI | https://localhost:44312 | http://localhost:9002 | http://host.docker.internal:9002 |
WebMVC | https://localhost:44364 | http://localhost:9003 | http://host.docker.internal:9003 |
GraphQL | https://localhost:44392 | http://localhost:9006 | http://host.docker.internal:9006 |
Ocelot | https://localhost:44340 | http://localhost:9007 | http://host.docker.internal:9007 |
Angular | http://localhost:4200/ | ||
React | http://localhost:3000/ | ||
Vue | http://localhost:8080/ |