From 67171643a07c2260f433205213e89d468da03ffc Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 22 Nov 2020 12:52:30 -0500 Subject: [PATCH 01/10] Looking in config for custom domain or default on Request Host --- src/shortenerTools/UrlList/UrlList.cs | 7 +++---- src/shortenerTools/UrlShortener/UrlShortener.cs | 4 +--- src/shortenerTools/UrlUpdate/UrlUpdate.cs | 3 +-- src/shortenerTools/settings.json | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/shortenerTools/UrlList/UrlList.cs b/src/shortenerTools/UrlList/UrlList.cs index 32d9fe5c..55aa5c10 100644 --- a/src/shortenerTools/UrlList/UrlList.cs +++ b/src/shortenerTools/UrlList/UrlList.cs @@ -60,14 +60,13 @@ public static async Task Run( } else { - userId = principal.FindFirst(ClaimTypes.GivenName).Value; - log.LogInformation("Authenticated user {user}.", userId); + userId = principal.FindFirst(ClaimTypes.GivenName).Value; + log.LogInformation("Authenticated user {user}.", userId); } result.UrlList = await stgHelper.GetAllShortUrlEntities(); result.UrlList = result.UrlList.Where(p => !(p.IsArchived ?? false)).ToList(); - //var host = req.HttpContext.RequestUri.GetLeftPart(UriPartial.Authority); - var host = req.Host.Host; + var host = string.IsNullOrEmpty(config["customDomain"]) ? req.Host.Host: config["customDomain"].ToString(); foreach (ShortUrlEntity url in result.UrlList) { url.ShortUrl = Utility.GetShortUrl(host, url.RowKey); diff --git a/src/shortenerTools/UrlShortener/UrlShortener.cs b/src/shortenerTools/UrlShortener/UrlShortener.cs index f2d70195..8a124e61 100644 --- a/src/shortenerTools/UrlShortener/UrlShortener.cs +++ b/src/shortenerTools/UrlShortener/UrlShortener.cs @@ -128,9 +128,7 @@ public static async Task Run( await stgHelper.SaveShortUrlEntity(newRow); - //var host = req.RequestUri.GetLeftPart(UriPartial.Authority); - var host = req.Host.Host; - log.LogInformation($"-> host = {host}"); + var host = string.IsNullOrEmpty(config["customDomain"]) ? req.Host.Host: config["customDomain"].ToString(); result = new ShortResponse(host, newRow.Url, newRow.RowKey, newRow.Title); log.LogInformation("Short Url created."); diff --git a/src/shortenerTools/UrlUpdate/UrlUpdate.cs b/src/shortenerTools/UrlUpdate/UrlUpdate.cs index 9caf1e4d..9961d5ed 100644 --- a/src/shortenerTools/UrlUpdate/UrlUpdate.cs +++ b/src/shortenerTools/UrlUpdate/UrlUpdate.cs @@ -115,8 +115,7 @@ public static async Task Run( StorageTableHelper stgHelper = new StorageTableHelper(config["UlsDataStorage"]); result = await stgHelper.UpdateShortUrlEntity(input); - //var host = req.RequestUri.GetLeftPart(UriPartial.Authority); - var host = req.Host.Host; + var host = string.IsNullOrEmpty(config["customDomain"]) ? req.Host.Host: config["customDomain"].ToString(); result.ShortUrl = Utility.GetShortUrl(host, result.RowKey); } diff --git a/src/shortenerTools/settings.json b/src/shortenerTools/settings.json index d9a7606f..7670fba1 100644 --- a/src/shortenerTools/settings.json +++ b/src/shortenerTools/settings.json @@ -5,7 +5,7 @@ "FUNCTIONS_WORKER_RUNTIME": "dotnet", "FUNCTIONS_V2_COMPATIBILITY_MODE":"true", "UlsDataStorage":"", - "defaultRedirectUrl":"https://azure.com" - + "defaultRedirectUrl":"https://azure.com", + "customDomain":"https://c5m.ca" } } From 17eb7c92c86aec037905b8490f983399b5ec0831 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:09:00 +0000 Subject: [PATCH 02/10] Bump Microsoft.Extensions.Configuration in /src/shortenerTools Bumps [Microsoft.Extensions.Configuration](https://github.com/dotnet/runtime) from 3.1.9 to 5.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/commits) Signed-off-by: dependabot[bot] --- src/shortenerTools/shortenerTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index 26d95204..f908f048 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -7,7 +7,7 @@ - + From 3e08544c453bfad4187626de0cfbb2ca715b8a88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:09:02 +0000 Subject: [PATCH 03/10] Bump Microsoft.AspNetCore.Identity.EntityFrameworkCore Bumps [Microsoft.AspNetCore.Identity.EntityFrameworkCore](https://github.com/dotnet/aspnetcore) from 3.1.9 to 5.0.0. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Commits](https://github.com/dotnet/aspnetcore/compare/v3.1.9...v5.0.0) Signed-off-by: dependabot[bot] --- src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj index 6c48a67a..fbf3c1c1 100644 --- a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj +++ b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj @@ -11,7 +11,7 @@ - + From 9eef88b6aa50d4f0b104460ae601dc037f6937a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:09:03 +0000 Subject: [PATCH 04/10] Bump Microsoft.EntityFrameworkCore.Tools Bumps [Microsoft.EntityFrameworkCore.Tools](https://github.com/dotnet/efcore) from 3.1.8 to 5.0.0. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v3.1.8...v5.0.0) Signed-off-by: dependabot[bot] --- src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj index 6c48a67a..13897507 100644 --- a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj +++ b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj @@ -15,7 +15,7 @@ - + From e0ad70e73034db42b632fceaab25b1ca8523c3b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:13:53 +0000 Subject: [PATCH 05/10] Bump Microsoft.NET.Sdk.Functions in /src/shortenerTools Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.9 to 3.0.11. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/compare/3.0.9...3.0.11) Signed-off-by: dependabot[bot] --- src/shortenerTools/shortenerTools.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shortenerTools/shortenerTools.csproj b/src/shortenerTools/shortenerTools.csproj index f908f048..cbe04a60 100644 --- a/src/shortenerTools/shortenerTools.csproj +++ b/src/shortenerTools/shortenerTools.csproj @@ -6,7 +6,7 @@ - + From 0a5515e96b0d75a6536ff4d7d9e82db8d311e9cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:14:24 +0000 Subject: [PATCH 06/10] Bump Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore Bumps [Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore](https://github.com/dotnet/aspnetcore) from 3.1.8 to 5.0.0. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Commits](https://github.com/dotnet/aspnetcore/compare/v3.1.8...v5.0.0) Signed-off-by: dependabot[bot] --- src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj index 4d1ea036..2adc82da 100644 --- a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj +++ b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj @@ -10,7 +10,7 @@ - + From 22be0a87a618c71ad4189dd93135af8d88eb2828 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:15:52 +0000 Subject: [PATCH 07/10] Bump Microsoft.EntityFrameworkCore.Sqlite Bumps [Microsoft.EntityFrameworkCore.Sqlite](https://github.com/dotnet/efcore) from 3.1.9 to 5.0.0. - [Release notes](https://github.com/dotnet/efcore/releases) - [Commits](https://github.com/dotnet/efcore/compare/v3.1.9...v5.0.0) Signed-off-by: dependabot[bot] --- src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj index 2adc82da..3ad596cf 100644 --- a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj +++ b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj @@ -13,7 +13,7 @@ - + From f88fb43198b464cc1b18e5f7cd1fd5c9c77d297e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2020 18:17:35 +0000 Subject: [PATCH 08/10] Bump Microsoft.AspNetCore.Identity.UI Bumps [Microsoft.AspNetCore.Identity.UI](https://github.com/dotnet/aspnetcore) from 3.1.9 to 5.0.0. - [Release notes](https://github.com/dotnet/aspnetcore/releases) - [Commits](https://github.com/dotnet/aspnetcore/compare/v3.1.9...v5.0.0) Signed-off-by: dependabot[bot] --- src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj index 3ad596cf..c54717be 100644 --- a/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj +++ b/src/adminTools/adminBlazorWebsite/src/adminBlazorWebsite.csproj @@ -12,7 +12,7 @@ - + From 3b4cf01fb3db37d098db64ea6bf6645d7f8c64e4 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 3 Dec 2020 15:10:10 -0500 Subject: [PATCH 09/10] adding video tutorial --- post-deployment-configuration.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/post-deployment-configuration.md b/post-deployment-configuration.md index 252f25c4..b1b7b454 100644 --- a/post-deployment-configuration.md +++ b/post-deployment-configuration.md @@ -4,6 +4,8 @@ Of course the beauty of a URL shortener is to have short link and this is done the best by a naked domain (domain.com). To realized this you would need to by an expensive certificate with a wild card, and this doesn't fit in the goals of this project. We will achieve it nervertheless by having a secure www.domain.com and doing a dynamic forward of domain.com to www.domain.com. +[](https://youtu.be/srZv8aj3ZP8) + ### 1- Assign a Domain to the Azure Function Let`s start by Adding a domain to the App Service. From 200d734b3f89a4a2880b97d61946bbc80b17dbcd Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 6 Dec 2020 16:16:32 -0500 Subject: [PATCH 10/10] update new custom domain documantation to fix mapping issue. --- post-deployment-configuration.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/post-deployment-configuration.md b/post-deployment-configuration.md index b1b7b454..3aeb45ab 100644 --- a/post-deployment-configuration.md +++ b/post-deployment-configuration.md @@ -6,6 +6,7 @@ Of course the beauty of a URL shortener is to have short link and this is done t [](https://youtu.be/srZv8aj3ZP8) +[https://youtu.be/srZv8aj3ZP8](https://youtu.be/srZv8aj3ZP8) ### 1- Assign a Domain to the Azure Function Let`s start by Adding a domain to the App Service. @@ -94,8 +95,22 @@ The URL shortener is now completly configured, and your users will be pleased. T The TinyBlazorAdmin is the place to manage all your URLs. Create a new Page rule to redirect all call to your domain and the prefix of your choice. ( ex: admin.07f.ca, manager.07f.ca, new.07f.ca, etc) + + + +### 5- Add the new Custom Domain to the Settings file + +The last step is to update the `src\shortenerTools\settings.json`. This is the setting file for the Azure Function. Add (or edit if already present) `customDomain` and set it to your new domain. + +``` + "customDomain":"https://c5m.ca" +``` + + Congradulation, you are all set! + + ---