From 9549786003d723493d865ba83420ed127bc34d53 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Sat, 27 May 2017 18:33:38 +0200 Subject: [PATCH 01/18] Remove basket.data from docker-compose --- docker-compose.override.yml | 1 - docker-compose.prod.yml | 1 - docker-compose.yml | 6 ------ 3 files changed, 8 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 04d1c4d9c..e7d1072ee 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -12,7 +12,6 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c5d8839ea..35fa2473c 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -17,7 +17,6 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.yml b/docker-compose.yml index 09212da8e..1af3b4787 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,6 @@ services: context: ./src/Services/Basket/Basket.API dockerfile: Dockerfile depends_on: - - basket.data - identity.api - rabbitmq @@ -59,11 +58,6 @@ services: sql.data: image: microsoft/mssql-server-linux - basket.data: - image: redis - ports: - - "6379:6379" - rabbitmq: image: rabbitmq ports: From b30d09fbf50e2160710d0107cf203f02333b68e9 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Sat, 27 May 2017 18:34:36 +0200 Subject: [PATCH 02/18] Add Redis connectionString to environment variable --- src/Services/Basket/Basket.API/appsettings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index 31f76d0d0..a44967e59 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -8,5 +8,5 @@ } }, "IdentityUrl": "http://localhost:5105", - "ConnectionString": "127.0.0.1" + "ConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false" } From c23d2551cde82bb0fdc7e8e74cedcd352c01e1cc Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Sat, 27 May 2017 18:35:28 +0200 Subject: [PATCH 03/18] Add new redis connection getting data from environment variable --- .../Basket.API/Model/RedisBasketRepository.cs | 24 +++++-------------- src/Services/Basket/Basket.API/Startup.cs | 11 ++++----- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/Services/Basket/Basket.API/Model/RedisBasketRepository.cs b/src/Services/Basket/Basket.API/Model/RedisBasketRepository.cs index 4ca90f383..e896c0773 100644 --- a/src/Services/Basket/Basket.API/Model/RedisBasketRepository.cs +++ b/src/Services/Basket/Basket.API/Model/RedisBasketRepository.cs @@ -4,7 +4,6 @@ using Newtonsoft.Json; using StackExchange.Redis; using System.Collections.Generic; using System.Linq; -using System.Net; using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.Services.Basket.API.Model @@ -16,12 +15,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model private ConnectionMultiplexer _redis; - public RedisBasketRepository(IOptionsSnapshot options, ILoggerFactory loggerFactory) { _settings = options.Value; _logger = loggerFactory.CreateLogger(); - } public async Task DeleteBasketAsync(string id) @@ -93,21 +90,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model } private async Task ConnectToRedisAsync() - { - // TODO: Need to make this more robust. ConnectionMultiplexer.ConnectAsync doesn't like domain names or IPv6 addresses. - if (IPAddress.TryParse(_settings.ConnectionString, out var ip)) - { - _redis = await ConnectionMultiplexer.ConnectAsync(ip.ToString()); - _logger.LogInformation($"Connecting to database at {_settings.ConnectionString}"); - } - else - { - // workaround for https://github.com/StackExchange/StackExchange.Redis/issues/410 - var ips = await Dns.GetHostAddressesAsync(_settings.ConnectionString); - _logger.LogInformation($"Connecting to database {_settings.ConnectionString} at IP {ips.First().ToString()}"); - _redis = await ConnectionMultiplexer.ConnectAsync(ips.First().ToString()); - } + { + var configuration = ConfigurationOptions.Parse(_settings.ConnectionString, true); + configuration.ResolveDns = true; + + _logger.LogInformation($"Connecting to database {configuration.SslHost}."); + _redis = await ConnectionMultiplexer.ConnectAsync(configuration); } - } } diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 855312a65..8f3735310 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -16,11 +16,8 @@ using Microsoft.Extensions.HealthChecks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using RabbitMQ.Client; -using StackExchange.Redis; -using System.Linq; -using System.Net; using System.Threading.Tasks; -using System; +using StackExchange.Redis; namespace Microsoft.eShopOnContainers.Services.Basket.API { @@ -64,12 +61,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API services.AddSingleton(sp => { var settings = sp.GetRequiredService>().Value; - var ips = Dns.GetHostAddressesAsync(settings.ConnectionString).Result; + var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); + configuration.ResolveDns = true; - return ConnectionMultiplexer.Connect(ips.First().ToString()); + return ConnectionMultiplexer.Connect(configuration); }); - services.AddSingleton(sp => { var settings = sp.GetRequiredService>().Value; From cd790f276f6a6710c788a42a4ac8f396c836393f Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Sat, 27 May 2017 18:35:44 +0200 Subject: [PATCH 04/18] Update StackExchange.Redis version --- src/Services/Basket/Basket.API/Basket.API.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index b3ba97b10..5f8765f40 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -22,6 +22,7 @@ + @@ -33,7 +34,6 @@ - From db7d2a3ff3d066d02599a1753d8b7af4865142bb Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 11:01:56 +0200 Subject: [PATCH 05/18] Add "AzureRedisConnectionString" environment variable and add a connectionString condition when "AzureRedisEnabled" environment variable is true --- src/Services/Basket/Basket.API/Startup.cs | 7 ++++++- src/Services/Basket/Basket.API/appsettings.json | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 8f3735310..f2f5afc91 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -61,7 +61,12 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API services.AddSingleton(sp => { var settings = sp.GetRequiredService>().Value; - var configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); + if (Configuration.GetValue("AzureRedisEnabled")) + { + settings.ConnectionString = Configuration["AzureRedisConnectionString"]; + } + + ConfigurationOptions configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); configuration.ResolveDns = true; return ConnectionMultiplexer.Connect(configuration); diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index a44967e59..43f70e202 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -8,5 +8,7 @@ } }, "IdentityUrl": "http://localhost:5105", - "ConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false" + "ConnectionString": "127.0.0.1", + "AzureRedisConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false", + "AzureRedisEnabled": "true" } From 60c08ce9c599f57fabbeebf0b581918fd0361329 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 11:06:22 +0200 Subject: [PATCH 06/18] Revert "Remove basket.data from docker-compose" This reverts commit 9549786003d723493d865ba83420ed127bc34d53. --- docker-compose.override.yml | 1 + docker-compose.prod.yml | 1 + docker-compose.yml | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index e7d1072ee..04d1c4d9c 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -12,6 +12,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 + - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 35fa2473c..c5d8839ea 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -17,6 +17,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://0.0.0.0:80 + - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.yml b/docker-compose.yml index 1af3b4787..09212da8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ services: context: ./src/Services/Basket/Basket.API dockerfile: Dockerfile depends_on: + - basket.data - identity.api - rabbitmq @@ -58,6 +59,11 @@ services: sql.data: image: microsoft/mssql-server-linux + basket.data: + image: redis + ports: + - "6379:6379" + rabbitmq: image: rabbitmq ports: From 0473a972252a4f164d724437c634cd02793b5947 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 12:42:51 +0200 Subject: [PATCH 07/18] change the "AzureRedisEnabled" condition to configure declaration --- src/Services/Basket/Basket.API/Startup.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index f2f5afc91..79adb1618 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -50,7 +50,14 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); - services.Configure(Configuration); + services.Configure(options => + { + Configuration.Bind(options); + if (Configuration.GetValue("AzureRedisEnabled")) + { + options.ConnectionString = Configuration["AzureRedisConnectionString"]; + } + }); //By connecting here we are making sure that our service //cannot start until redis is ready. This might slow down startup, @@ -61,11 +68,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API services.AddSingleton(sp => { var settings = sp.GetRequiredService>().Value; - if (Configuration.GetValue("AzureRedisEnabled")) - { - settings.ConnectionString = Configuration["AzureRedisConnectionString"]; - } - ConfigurationOptions configuration = ConfigurationOptions.Parse(settings.ConnectionString, true); configuration.ResolveDns = true; From 2d4f9d332360ae2b35f051b65d9631dc1128d1af Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 15:42:09 +0200 Subject: [PATCH 08/18] Add ESHOP_AZURE_SERVICE_BUS variable from .env with default value --- docker-compose.override.yml | 8 ++++---- docker-compose.prod.yml | 8 ++++---- docker-compose.vs.debug.yml | 2 +- docker-compose.vs.release.yml | 2 +- docker-compose.yml | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 04d1c4d9c..3d63a5547 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' # The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine. # The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: @@ -14,7 +14,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5103:80" @@ -24,7 +24,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word - ExternalCatalogBaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5101 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5101:80" @@ -45,7 +45,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5102:80" diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c5d8839ea..30a8c764f 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' # The Production docker-compose file has to have the external/real IPs or DNS names for the services # The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: @@ -19,7 +19,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=basket.data - identityUrl=http://identity.api #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5103:80" @@ -29,7 +29,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word - ExternalCatalogBaseUrl=http://${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}:5101 #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5101:80" @@ -50,7 +50,7 @@ services: - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word - identityUrl=http://identity.api #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - - EventBusConnection=rabbitmq + - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} ports: - "5102:80" diff --git a/docker-compose.vs.debug.yml b/docker-compose.vs.debug.yml index 2e7145637..413940bef 100644 --- a/docker-compose.vs.debug.yml +++ b/docker-compose.vs.debug.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.vs.release.yml b/docker-compose.vs.release.yml index d1ca5b2c6..6637b71b5 100644 --- a/docker-compose.vs.release.yml +++ b/docker-compose.vs.release.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.yml b/docker-compose.yml index 09212da8e..6a0953706 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: From e309d97d18c53959ce94a636e7ea1905564ed14d Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 16:03:51 +0200 Subject: [PATCH 09/18] remove AzureRedisConnectionString variable from settings --- src/Services/Basket/Basket.API/appsettings.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index 43f70e202..3a5b1b0b9 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -7,8 +7,5 @@ "Microsoft": "Information" } }, - "IdentityUrl": "http://localhost:5105", - "ConnectionString": "127.0.0.1", - "AzureRedisConnectionString": "eshoponazure.redis.cache.windows.net:6379,password=I9t4YmytcxvAjThGz98oUbfcI0Zcu7sIB2nhmmDxjVo=,ssl=false,abortConnect=false", - "AzureRedisEnabled": "true" + "IdentityUrl": "http://localhost:5105" } From 6b480e3d41f6eaaf8737ff20752dd624c6007185 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Mon, 29 May 2017 16:04:35 +0200 Subject: [PATCH 10/18] Apply ConnectionString changes (remove condition) --- src/Services/Basket/Basket.API/Startup.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 79adb1618..dd20b9353 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -50,14 +50,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API options.Filters.Add(typeof(HttpGlobalExceptionFilter)); }).AddControllersAsServices(); - services.Configure(options => - { - Configuration.Bind(options); - if (Configuration.GetValue("AzureRedisEnabled")) - { - options.ConnectionString = Configuration["AzureRedisConnectionString"]; - } - }); + services.Configure(Configuration); //By connecting here we are making sure that our service //cannot start until redis is ready. This might slow down startup, From 45ed8a60ad87c0da8f84f93aae143dce7e9c8bcc Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:14:28 +0200 Subject: [PATCH 11/18] Add PictureFileName field for saving the name of the file. PictureUri will be the url of the image (api or azure storage) --- .../Infrastructure/CatalogContext.cs | 4 +- .../Infrastructure/CatalogContextSeed.cs | 24 ++--- ...70530133114_AddPictureFileName.Designer.cs | 99 +++++++++++++++++++ .../20170530133114_AddPictureFileName.cs | 25 +++++ .../CatalogContextModelSnapshot.cs | 2 +- .../Catalog/Catalog.API/Model/CatalogItem.cs | 2 + 6 files changed, 142 insertions(+), 14 deletions(-) create mode 100644 src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs create mode 100644 src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.cs diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs index cd26632e0..f58541b62 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContext.cs @@ -36,9 +36,11 @@ builder.Property(ci => ci.Price) .IsRequired(true); - builder.Property(ci => ci.PictureUri) + builder.Property(ci => ci.PictureFileName) .IsRequired(false); + builder.Ignore(ci => ci.PictureUri); + builder.HasOne(ci => ci.CatalogBrand) .WithMany() .HasForeignKey(ci => ci.CatalogBrandId); diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs index 5f2370fb6..e6bb1dafe 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogContextSeed.cs @@ -70,18 +70,18 @@ { return new List() { - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Bot Black Hoodie", Name = ".NET Bot Black Hoodie", Price = 19.5M, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/1" }, - new CatalogItem() { CatalogTypeId=1,CatalogBrandId=2, Description = ".NET Black & White Mug", Name = ".NET Black & White Mug", Price= 8.50M, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/2" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White T-Shirt", Name = "Prism White T-Shirt", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/3" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Foundation T-shirt", Name = ".NET Foundation T-shirt", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/4" }, - new CatalogItem() { CatalogTypeId=3,CatalogBrandId=5, Description = "Roslyn Red Sheet", Name = "Roslyn Red Sheet", Price = 8.5M, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/5" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Blue Hoodie", Name = ".NET Blue Hoodie", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/6" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Roslyn Red T-Shirt", Name = "Roslyn Red T-Shirt", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/7" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Kudu Purple Hoodie", Name = "Kudu Purple Hoodie", Price = 8.5M, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/8" }, - new CatalogItem() { CatalogTypeId=1,CatalogBrandId=5, Description = "Cup White Mug", Name = "Cup White Mug", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/9" }, - new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = ".NET Foundation Sheet", Name = ".NET Foundation Sheet", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/10" }, - new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = "Cup Sheet", Name = "Cup Sheet", Price = 8.5M, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/11" }, - new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White TShirt", Name = "Prism White TShirt", Price = 12, PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/pic/12" } + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Bot Black Hoodie", Name = ".NET Bot Black Hoodie", Price = 19.5M, PictureFileName = "1.png" }, + new CatalogItem() { CatalogTypeId=1,CatalogBrandId=2, Description = ".NET Black & White Mug", Name = ".NET Black & White Mug", Price= 8.50M, PictureFileName = "2.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White T-Shirt", Name = "Prism White T-Shirt", Price = 12, PictureFileName = "3.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Foundation T-shirt", Name = ".NET Foundation T-shirt", Price = 12, PictureFileName = "4.png" }, + new CatalogItem() { CatalogTypeId=3,CatalogBrandId=5, Description = "Roslyn Red Sheet", Name = "Roslyn Red Sheet", Price = 8.5M, PictureFileName = "5.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=2, Description = ".NET Blue Hoodie", Name = ".NET Blue Hoodie", Price = 12, PictureFileName = "6.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Roslyn Red T-Shirt", Name = "Roslyn Red T-Shirt", Price = 12, PictureFileName = "7.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Kudu Purple Hoodie", Name = "Kudu Purple Hoodie", Price = 8.5M, PictureFileName = "8.png" }, + new CatalogItem() { CatalogTypeId=1,CatalogBrandId=5, Description = "Cup White Mug", Name = "Cup White Mug", Price = 12, PictureFileName = "9.png" }, + new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = ".NET Foundation Sheet", Name = ".NET Foundation Sheet", Price = 12, PictureFileName = "10.png" }, + new CatalogItem() { CatalogTypeId=3,CatalogBrandId=2, Description = "Cup Sheet", Name = "Cup Sheet", Price = 8.5M, PictureFileName = "11.png" }, + new CatalogItem() { CatalogTypeId=2,CatalogBrandId=5, Description = "Prism White TShirt", Name = "Prism White TShirt", Price = 12, PictureFileName = "12.png" }, }; } } diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs new file mode 100644 index 000000000..ebfabd154 --- /dev/null +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs @@ -0,0 +1,99 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; + +namespace Catalog.API.Infrastructure.Migrations +{ + [DbContext(typeof(CatalogContext))] + [Migration("20170530133114_AddPictureFile")] + partial class AddPictureFile + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.1.1") + .HasAnnotation("SqlServer:Sequence:.catalog_brand_hilo", "'catalog_brand_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:.catalog_hilo", "'catalog_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:.catalog_type_hilo", "'catalog_type_hilo', '', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogBrand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_brand_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("Brand") + .IsRequired() + .HasMaxLength(100); + + b.HasKey("Id"); + + b.ToTable("CatalogBrand"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("CatalogBrandId"); + + b.Property("CatalogTypeId"); + + b.Property("Description"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50); + + b.Property("PictureFile"); + + b.Property("Price"); + + b.HasKey("Id"); + + b.HasIndex("CatalogBrandId"); + + b.HasIndex("CatalogTypeId"); + + b.ToTable("Catalog"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "catalog_type_hilo") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100); + + b.HasKey("Id"); + + b.ToTable("CatalogType"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogItem", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogBrand", "CatalogBrand") + .WithMany() + .HasForeignKey("CatalogBrandId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopOnContainers.Services.Catalog.API.Model.CatalogType", "CatalogType") + .WithMany() + .HasForeignKey("CatalogTypeId") + .OnDelete(DeleteBehavior.Cascade); + }); + } + } +} diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.cs new file mode 100644 index 000000000..fc7f4dc8d --- /dev/null +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Catalog.API.Infrastructure.Migrations +{ + public partial class AddPictureFile : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PictureUri", + table: "Catalog", + newName: "PictureFileName"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PictureFileName", + table: "Catalog", + newName: "PictureUri"); + } + } +} diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/CatalogContextModelSnapshot.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/CatalogContextModelSnapshot.cs index ba1151672..020ef3de2 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/CatalogContextModelSnapshot.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/CatalogContextModelSnapshot.cs @@ -52,7 +52,7 @@ namespace Catalog.API.Infrastructure.Migrations .IsRequired() .HasMaxLength(50); - b.Property("PictureUri"); + b.Property("PictureFileName"); b.Property("Price"); diff --git a/src/Services/Catalog/Catalog.API/Model/CatalogItem.cs b/src/Services/Catalog/Catalog.API/Model/CatalogItem.cs index a232cb2fe..8e7bb5d21 100644 --- a/src/Services/Catalog/Catalog.API/Model/CatalogItem.cs +++ b/src/Services/Catalog/Catalog.API/Model/CatalogItem.cs @@ -12,6 +12,8 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model public decimal Price { get; set; } + public string PictureFileName { get; set; } + public string PictureUri { get; set; } public int CatalogTypeId { get; set; } From 1a385a21791a181a19fda7596610732f917c4740 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:16:17 +0200 Subject: [PATCH 12/18] Add AzureStorageEnabled environment variable to get the origin of the product image from PicBaseUrl environment variable --- .../Catalog/Catalog.API/CatalogSettings.cs | 4 ++- .../Controllers/CatalogController.cs | 13 ++++--- .../Catalog.API/Controllers/PicController.cs | 34 +++++++++++++++---- .../Catalog/Catalog.API/settings.json | 3 +- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/Services/Catalog/Catalog.API/CatalogSettings.cs b/src/Services/Catalog/Catalog.API/CatalogSettings.cs index 62e92c6ce..03bb584f3 100644 --- a/src/Services/Catalog/Catalog.API/CatalogSettings.cs +++ b/src/Services/Catalog/Catalog.API/CatalogSettings.cs @@ -2,10 +2,12 @@ { public class CatalogSettings { - public string ExternalCatalogBaseUrl {get;set;} + public string PicBaseUrl { get;set;} public string EventBusConnection { get; set; } public string ServiceBusConnectionString { get; set; } + + public bool AzureStorageEnabled { get; set; } } } diff --git a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs index 374d8ec7c..ca1ef9e3b 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs @@ -200,7 +200,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers CatalogTypeId = product.CatalogTypeId, Description = product.Description, Name = product.Name, - PictureUri = product.PictureUri, + PictureFileName = product.PictureFileName, Price = product.Price }; _catalogContext.CatalogItems.Add(item); @@ -231,11 +231,14 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers private List ChangeUriPlaceholder(List items) { - var baseUri = _settings.ExternalCatalogBaseUrl; - - items.ForEach(x => + var baseUri = _settings.PicBaseUrl; + + items.ForEach(catalogItem => { - x.PictureUri = x.PictureUri.Replace("http://externalcatalogbaseurltobereplaced", baseUri); + catalogItem.PictureUri = _settings.AzureStorageEnabled + ? baseUri + catalogItem.PictureFileName + : baseUri + catalogItem.Id; + }); return items; diff --git a/src/Services/Catalog/Catalog.API/Controllers/PicController.cs b/src/Services/Catalog/Catalog.API/Controllers/PicController.cs index 8d8aaf9f2..a2106bead 100644 --- a/src/Services/Catalog/Catalog.API/Controllers/PicController.cs +++ b/src/Services/Catalog/Catalog.API/Controllers/PicController.cs @@ -1,6 +1,9 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure; using System.IO; +using System.Threading.Tasks; // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 @@ -10,21 +13,38 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers public class PicController : Controller { private readonly IHostingEnvironment _env; - public PicController(IHostingEnvironment env) + private readonly CatalogContext _catalogContext; + + public PicController(IHostingEnvironment env, + CatalogContext catalogContext) { _env = env; + _catalogContext = catalogContext; } [HttpGet("{id}")] // GET: // - public IActionResult GetImage(int id) + public async Task GetImage(int id) { - var webRoot = _env.WebRootPath; - var path = Path.Combine(webRoot, id + ".png"); + if (id <= 0) + { + return BadRequest(); + } + + var item = await _catalogContext.CatalogItems + .SingleOrDefaultAsync(ci => ci.Id == id); + + if (item != null) + { + var webRoot = _env.WebRootPath; + var path = Path.Combine(webRoot, item.PictureFileName); + + var buffer = System.IO.File.ReadAllBytes(path); + + return File(buffer, "image/png"); + } - var buffer = System.IO.File.ReadAllBytes(path); - - return File(buffer, "image/png"); + return NotFound(); } } } diff --git a/src/Services/Catalog/Catalog.API/settings.json b/src/Services/Catalog/Catalog.API/settings.json index 3cfe64f5e..b431cf8f0 100644 --- a/src/Services/Catalog/Catalog.API/settings.json +++ b/src/Services/Catalog/Catalog.API/settings.json @@ -1,6 +1,6 @@ { "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word", - "ExternalCatalogBaseUrl": "http://localhost:5101", + "PicBaseUrl": "http://localhost:5101", "Logging": { "IncludeScopes": false, "LogLevel": { @@ -11,5 +11,6 @@ }, "ServiceBusConnectionString": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=oA6WpfCfCbScZbQa/DBOLfwl6oi5ezPsCYL7QsTb4PY=;EntityPath=eshop_event_bus", "AzureServiceBusEnabled": "true", + "AzureStorageEnabled": false, "SubscriptionClientName": "Catalog" } From 9866aae07c03d42c72ccfc574ab94e491942291b Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:24:46 +0200 Subject: [PATCH 13/18] Change version of docker-compose from 2 to 2.1 for default values. I set "http://localhost:5101/api/v1/pic/" because docker-compose doesn't allow to declare another variable such as default value --- docker-compose.override.yml | 4 ++-- docker-compose.vs.debug.yml | 2 +- docker-compose.vs.release.yml | 2 +- docker-compose.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 04d1c4d9c..945accc67 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' # The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine. # The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: @@ -23,7 +23,7 @@ services: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word - - ExternalCatalogBaseUrl=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5101 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. + - PicBaseUrl=${ESHOP_AZURE_STORAGE_ACCOUNT:-http://localhost:5101/api/v1/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: - "5101:80" diff --git a/docker-compose.vs.debug.yml b/docker-compose.vs.debug.yml index 2e7145637..413940bef 100644 --- a/docker-compose.vs.debug.yml +++ b/docker-compose.vs.debug.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.vs.release.yml b/docker-compose.vs.release.yml index d1ca5b2c6..6637b71b5 100644 --- a/docker-compose.vs.release.yml +++ b/docker-compose.vs.release.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.yml b/docker-compose.yml index 09212da8e..6a0953706 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: From 2cad62d642905979f3f9be9ded769d966c230548 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:30:01 +0200 Subject: [PATCH 14/18] Add ESHOP_AZURE_REDIS variable from .env with default value --- docker-compose.override.yml | 4 ++-- docker-compose.prod.yml | 4 ++-- docker-compose.vs.debug.yml | 2 +- docker-compose.vs.release.yml | 2 +- docker-compose.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 04d1c4d9c..c5666d6fa 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' # The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine. # The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: @@ -12,7 +12,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=basket.data + - ConnectionString=${ESHOP_AZURE_REDIS:-basket.data} - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c5d8839ea..739d4f218 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' # The Production docker-compose file has to have the external/real IPs or DNS names for the services # The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like: @@ -17,7 +17,7 @@ services: environment: - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://0.0.0.0:80 - - ConnectionString=basket.data + - ConnectionString=${ESHOP_AZURE_REDIS:-basket.data} - identityUrl=http://identity.api #Local: You need to open your host's firewall at range 5100-5105. at range 5100-5105. - EventBusConnection=rabbitmq ports: diff --git a/docker-compose.vs.debug.yml b/docker-compose.vs.debug.yml index 2e7145637..413940bef 100644 --- a/docker-compose.vs.debug.yml +++ b/docker-compose.vs.debug.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.vs.release.yml b/docker-compose.vs.release.yml index d1ca5b2c6..6637b71b5 100644 --- a/docker-compose.vs.release.yml +++ b/docker-compose.vs.release.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: diff --git a/docker-compose.yml b/docker-compose.yml index 09212da8e..6a0953706 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '2.1' services: basket.api: From 7694602be247c7d1a1d198e290b620d0e6cb1f70 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:53:15 +0200 Subject: [PATCH 15/18] Rename property PictureFile to PictureFileName in Migration Designer --- .../20170530133114_AddPictureFileName.Designer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs index ebfabd154..23c0e5344 100644 --- a/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs +++ b/src/Services/Catalog/Catalog.API/Infrastructure/CatalogMigrations/20170530133114_AddPictureFileName.Designer.cs @@ -53,7 +53,7 @@ namespace Catalog.API.Infrastructure.Migrations .IsRequired() .HasMaxLength(50); - b.Property("PictureFile"); + b.Property("PictureFileName"); b.Property("Price"); From 83ae0d48fcee2da667290d3d3d425571bffdf6b5 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:56:36 +0200 Subject: [PATCH 16/18] remove ServiceBusConnectionString variable from appsettings.json --- src/Services/Basket/Basket.API/BasketSettings.cs | 2 -- src/Services/Basket/Basket.API/appsettings.json | 1 - src/Services/Catalog/Catalog.API/CatalogSettings.cs | 2 -- src/Services/Catalog/Catalog.API/settings.json | 1 - src/Services/Ordering/Ordering.API/settings.json | 1 - 5 files changed, 7 deletions(-) diff --git a/src/Services/Basket/Basket.API/BasketSettings.cs b/src/Services/Basket/Basket.API/BasketSettings.cs index 721461a1c..9d143545a 100644 --- a/src/Services/Basket/Basket.API/BasketSettings.cs +++ b/src/Services/Basket/Basket.API/BasketSettings.cs @@ -5,7 +5,5 @@ public string ConnectionString { get; set; } public string EventBusConnection { get; set; } - - public string ServiceBusConnectionString { get; set; } } } diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index 718639474..6d49d9475 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -9,7 +9,6 @@ }, "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1", - "ServiceBusConnectionString": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=oA6WpfCfCbScZbQa/DBOLfwl6oi5ezPsCYL7QsTb4PY=;EntityPath=eshop_event_bus", "AzureServiceBusEnabled": "true", "SubscriptionClientName": "Basket" } \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/CatalogSettings.cs b/src/Services/Catalog/Catalog.API/CatalogSettings.cs index 62e92c6ce..af6e0ab13 100644 --- a/src/Services/Catalog/Catalog.API/CatalogSettings.cs +++ b/src/Services/Catalog/Catalog.API/CatalogSettings.cs @@ -5,7 +5,5 @@ public string ExternalCatalogBaseUrl {get;set;} public string EventBusConnection { get; set; } - - public string ServiceBusConnectionString { get; set; } } } diff --git a/src/Services/Catalog/Catalog.API/settings.json b/src/Services/Catalog/Catalog.API/settings.json index 3cfe64f5e..82bbc4c1d 100644 --- a/src/Services/Catalog/Catalog.API/settings.json +++ b/src/Services/Catalog/Catalog.API/settings.json @@ -9,7 +9,6 @@ "Microsoft": "Information" } }, - "ServiceBusConnectionString": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=oA6WpfCfCbScZbQa/DBOLfwl6oi5ezPsCYL7QsTb4PY=;EntityPath=eshop_event_bus", "AzureServiceBusEnabled": "true", "SubscriptionClientName": "Catalog" } diff --git a/src/Services/Ordering/Ordering.API/settings.json b/src/Services/Ordering/Ordering.API/settings.json index 1270a34f6..00970cbec 100644 --- a/src/Services/Ordering/Ordering.API/settings.json +++ b/src/Services/Ordering/Ordering.API/settings.json @@ -9,7 +9,6 @@ "Microsoft": "Information" } }, - "ServiceBusConnectionString": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=oA6WpfCfCbScZbQa/DBOLfwl6oi5ezPsCYL7QsTb4PY=;EntityPath=eshop_event_bus", "AzureServiceBusEnabled": "true", "SubscriptionClientName": "Ordering" } From 18167186c9b3f5ed3b616cb9e73f33a05be56dab Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 17:59:57 +0200 Subject: [PATCH 17/18] Apply EventBusConnectionChanges --- src/Services/Basket/Basket.API/Startup.cs | 2 +- src/Services/Basket/Basket.API/appsettings.json | 2 +- src/Services/Catalog/Catalog.API/Startup.cs | 2 +- src/Services/Catalog/Catalog.API/settings.json | 2 +- src/Services/Ordering/Ordering.API/Startup.cs | 2 +- src/Services/Ordering/Ordering.API/settings.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 9c975d4ff..ea4c8cad4 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -79,7 +79,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API var settings = sp.GetRequiredService>().Value; var logger = sp.GetRequiredService>(); - var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.ServiceBusConnectionString); + var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.EventBusConnection); return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger); }); diff --git a/src/Services/Basket/Basket.API/appsettings.json b/src/Services/Basket/Basket.API/appsettings.json index 6d49d9475..f062f76d7 100644 --- a/src/Services/Basket/Basket.API/appsettings.json +++ b/src/Services/Basket/Basket.API/appsettings.json @@ -9,6 +9,6 @@ }, "IdentityUrl": "http://localhost:5105", "ConnectionString": "127.0.0.1", - "AzureServiceBusEnabled": "true", + "AzureServiceBusEnabled": false, "SubscriptionClientName": "Basket" } \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 25255cbaa..edc63c29d 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -118,7 +118,7 @@ var settings = sp.GetRequiredService>().Value; var logger = sp.GetRequiredService>(); - var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.ServiceBusConnectionString); + var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.EventBusConnection); return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger); }); diff --git a/src/Services/Catalog/Catalog.API/settings.json b/src/Services/Catalog/Catalog.API/settings.json index 82bbc4c1d..29d7240f6 100644 --- a/src/Services/Catalog/Catalog.API/settings.json +++ b/src/Services/Catalog/Catalog.API/settings.json @@ -9,6 +9,6 @@ "Microsoft": "Information" } }, - "AzureServiceBusEnabled": "true", + "AzureServiceBusEnabled": false, "SubscriptionClientName": "Catalog" } diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 7728725c1..9116a3ad2 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -121,7 +121,7 @@ { var logger = sp.GetRequiredService>(); - var serviceBusConnectionString = Configuration["ServiceBusConnectionString"]; + var serviceBusConnectionString = Configuration["EventBusConnection"]; var serviceBusConnection = new ServiceBusConnectionStringBuilder(serviceBusConnectionString); return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger); diff --git a/src/Services/Ordering/Ordering.API/settings.json b/src/Services/Ordering/Ordering.API/settings.json index 00970cbec..9f1c58322 100644 --- a/src/Services/Ordering/Ordering.API/settings.json +++ b/src/Services/Ordering/Ordering.API/settings.json @@ -9,6 +9,6 @@ "Microsoft": "Information" } }, - "AzureServiceBusEnabled": "true", + "AzureServiceBusEnabled": false, "SubscriptionClientName": "Ordering" } From 4d07fecc3b026be68b795b6a29531a04a056ab54 Mon Sep 17 00:00:00 2001 From: Christian Arenas Date: Tue, 30 May 2017 18:35:09 +0200 Subject: [PATCH 18/18] fix merge error --- src/Services/Basket/Basket.API/Startup.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 0888fad6c..a5b5a35aa 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -18,6 +18,8 @@ using Microsoft.Extensions.Options; using RabbitMQ.Client; using System.Threading.Tasks; using StackExchange.Redis; +using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus; +using Microsoft.Azure.ServiceBus; namespace Microsoft.eShopOnContainers.Services.Basket.API {