diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj
index 644b865bb..850660fdc 100644
--- a/src/Services/Basket/Basket.API/Basket.API.csproj
+++ b/src/Services/Basket/Basket.API/Basket.API.csproj
@@ -2,6 +2,7 @@
net7.0
..\..\..\..\docker-compose.dcproj
+ 2964ec8e-0d48-4541-b305-94cab537f867
diff --git a/src/Services/Basket/Basket.API/Properties/serviceDependencies.json b/src/Services/Basket/Basket.API/Properties/serviceDependencies.json
new file mode 100644
index 000000000..696e09f1b
--- /dev/null
+++ b/src/Services/Basket/Basket.API/Properties/serviceDependencies.json
@@ -0,0 +1,12 @@
+{
+ "dependencies": {
+ "secrets1": {
+ "type": "secrets"
+ },
+ "rabbitmq1": {
+ "type": "rabbitmq",
+ "connectionId": "eventbus",
+ "dynamicId": null
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Services/Basket/Basket.API/Properties/serviceDependencies.local.json b/src/Services/Basket/Basket.API/Properties/serviceDependencies.local.json
new file mode 100644
index 000000000..81f47080f
--- /dev/null
+++ b/src/Services/Basket/Basket.API/Properties/serviceDependencies.local.json
@@ -0,0 +1,16 @@
+{
+ "dependencies": {
+ "secrets1": {
+ "type": "secrets.user"
+ },
+ "rabbitmq1": {
+ "containerPorts": "5672:5672,15672:15672",
+ "secretStore": "LocalSecretsFile",
+ "containerName": "rabbitmq",
+ "containerImage": "rabbitmq:3-management-alpine",
+ "type": "rabbitmq.container",
+ "connectionId": "eventbus",
+ "dynamicId": null
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json
index 171521d27..f425b8f17 100644
--- a/src/Services/Basket/Basket.API/appsettings.json
+++ b/src/Services/Basket/Basket.API/appsettings.json
@@ -20,7 +20,8 @@
}
},
"ConnectionStrings": {
- "Redis": "localhost"
+ "Redis": "localhost",
+ "EventBus": "localhost"
},
"Identity": {
"Audience": "basket",
@@ -30,7 +31,6 @@
},
"EventBus": {
"SubscriptionClientName": "Basket",
- "ConnectionString": "localhost",
"RetryCount": 5
}
}
diff --git a/src/Services/Identity/Identity.API/ProgramExtensions.cs b/src/Services/Identity/Identity.API/ProgramExtensions.cs
index ac869b6ae..19f5e71d2 100644
--- a/src/Services/Identity/Identity.API/ProgramExtensions.cs
+++ b/src/Services/Identity/Identity.API/ProgramExtensions.cs
@@ -41,7 +41,7 @@ public static class ProgramExtensions
public static void AddCustomDatabase(this WebApplicationBuilder builder) =>
builder.Services.AddDbContext(
- options => options.UseSqlServer(builder.Configuration["ConnectionString"]));
+ options => options.UseSqlServer(builder.Configuration.GetConnectionString("IdentityDb")));
public static void AddCustomIdentity(this WebApplicationBuilder builder)
{
@@ -82,7 +82,7 @@ public static class ProgramExtensions
{
builder.Services.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy())
- .AddSqlServer(builder.Configuration["ConnectionString"],
+ .AddSqlServer(builder.Configuration.GetConnectionString("IdentityDb"),
name: "IdentityDB-check",
tags: new string[] { "IdentityDB" });
}
diff --git a/src/Services/Identity/Identity.API/Properties/serviceDependencies.json b/src/Services/Identity/Identity.API/Properties/serviceDependencies.json
new file mode 100644
index 000000000..718987b23
--- /dev/null
+++ b/src/Services/Identity/Identity.API/Properties/serviceDependencies.json
@@ -0,0 +1,9 @@
+{
+ "dependencies": {
+ "mssql1": {
+ "type": "mssql",
+ "connectionId": "ConnectionString",
+ "dynamicId": null
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Services/Identity/Identity.API/Properties/serviceDependencies.local.json b/src/Services/Identity/Identity.API/Properties/serviceDependencies.local.json
new file mode 100644
index 000000000..cae5e3931
--- /dev/null
+++ b/src/Services/Identity/Identity.API/Properties/serviceDependencies.local.json
@@ -0,0 +1,14 @@
+{
+ "dependencies": {
+ "mssql1": {
+ "serviceConnectorResourceId": "",
+ "containerPorts": "1433:1433",
+ "secretStore": "LocalSecretsFile",
+ "containerName": "identity-sql",
+ "containerImage": "mcr.microsoft.com/mssql/server:2019-latest",
+ "type": "mssql.container",
+ "connectionId": "ConnectionString",
+ "dynamicId": null
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Services/Identity/Identity.API/appsettings.json b/src/Services/Identity/Identity.API/appsettings.json
index 1f239f782..cc37da9fe 100644
--- a/src/Services/Identity/Identity.API/appsettings.json
+++ b/src/Services/Identity/Identity.API/appsettings.json
@@ -1,5 +1,4 @@
{
- "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word;Encrypt=False;TrustServerCertificate=true;",
"IsClusterEnv": "False",
"MvcClient": "http://localhost:5100",
"SpaClient": "http://localhost:5104",
diff --git a/src/Services/Services.Common/CommonExtensions.cs b/src/Services/Services.Common/CommonExtensions.cs
index a523eef83..bd1297682 100644
--- a/src/Services/Services.Common/CommonExtensions.cs
+++ b/src/Services/Services.Common/CommonExtensions.cs
@@ -271,12 +271,12 @@ public static class CommonExtensions
// {
// "EventBus": {
// "ProviderName": "ServiceBus | RabbitMQ",
- // "ConnectionString": "..."
+
// }
// }
var eventBusSection = configuration.GetRequiredSection("EventBus");
- var eventBusConnectionString = eventBusSection.GetRequiredValue("ConnectionString");
+ var eventBusConnectionString = configuration.GetRequiredConnectionString("EventBus");
return eventBusSection["ProviderName"]?.ToLowerInvariant() switch
{
@@ -295,10 +295,14 @@ public static class CommonExtensions
public static IServiceCollection AddEventBus(this IServiceCollection services, IConfiguration configuration)
{
+ // {
+ // "ConnectionStrings": {
+ // "EventBus": "..."
+ // },
+
// {
// "EventBus": {
// "ProviderName": "ServiceBus | RabbitMQ",
- // "ConnectionString": "...",
// ...
// }
// }
@@ -306,7 +310,6 @@ public static class CommonExtensions
// {
// "EventBus": {
// "ProviderName": "ServiceBus",
- // "ConnectionString": "..."
// "SubscriptionClientName": "eshop_event_bus"
// }
// }
@@ -314,7 +317,6 @@ public static class CommonExtensions
// {
// "EventBus": {
// "ProviderName": "RabbitMQ",
- // "ConnectionString": "...",
// "SubscriptionClientName": "...",
// "UserName": "...",
// "Password": "...",
@@ -327,7 +329,7 @@ public static class CommonExtensions
{
services.AddSingleton(sp =>
{
- var serviceBusConnectionString = eventBusSection.GetRequiredValue("ConnectionString");
+ var serviceBusConnectionString = configuration.GetRequiredConnectionString("EventBus");
return new DefaultServiceBusPersisterConnection(serviceBusConnectionString);
});
@@ -351,7 +353,7 @@ public static class CommonExtensions
var factory = new ConnectionFactory()
{
- HostName = eventBusSection.GetRequiredValue("ConnectionString"),
+ HostName = configuration.GetRequiredConnectionString("EventBus"),
DispatchConsumersAsync = true
};
@@ -432,4 +434,7 @@ public static class CommonExtensions
private static string GetRequiredValue(this IConfiguration configuration, string name) =>
configuration[name] ?? throw new InvalidOperationException($"Configuration missing value for: {(configuration is IConfigurationSection s ? s.Path + ":" + name : name)}");
+
+ private static string GetRequiredConnectionString(this IConfiguration configuration, string name) =>
+ configuration.GetConnectionString(name) ?? throw new InvalidOperationException($"Configuration missing value for: {(configuration is IConfigurationSection s ? s.Path + ":ConnectionStrings:" + name : "ConnectionStrings:" + name)}");
}