Skip to content

Commit 7a1d28b

Browse files
authored
This is version 4 (#549)
* Update time ALL to latest * .NET Aspire solution * Azure Container Apps (instead of SWA and Function) * Deployment with Azure developer CLI (azd) * Replace Syncfusion components with Blazor Bootstrap and update chart implementation * Update GitHub Actions workflow to include 'v-next' branch and clean up indentation * Add FAQ documentation (planning to deprecate the wiki) * Update readme and images
1 parent 7b11c71 commit 7a1d28b

File tree

143 files changed

+3366
-3497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+3366
-3497
lines changed

.github/workflows/azure-static-web-apps-kind-ocean-0b86fe110.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v-next
8+
pull_request:
9+
branches:
10+
- main
11+
- v-next
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up .NET
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: '9.0.x' # Adjust the version as needed
25+
26+
- name: Install .NET Aspire workload
27+
run: dotnet workload update && dotnet workload install aspire
28+
29+
- name: Restore dependencies
30+
run: dotnet restore src/AzUrlShortener.sln
31+
32+
- name: Build solution
33+
run: dotnet build src/AzUrlShortener.sln --no-restore --configuration Release

Media/TinyBlazorAdmin.gif

-384 KB
Binary file not shown.

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ Features:
2020
- Budget-friendly and 100% open-source.
2121
- Extensible for more enterprise-friendly configurations
2222
- Simple step by step deployment.
23+
2324

2425
## How To Deploy
2526

26-
👉 **[Step by Step Deployment](https://github.com/microsoft/AzUrlShortener/wiki/How-to-deploy-your-AzUrlShortener)** (wiki pages) 👈 documentation is available here. If you would like to used the TinyBlazorAdmin as frontend (suggested) **you must first** follow the [steps to follow for TinyBlazorAdmin](https://github.com/microsoft/AzUrlShortener/wiki/How-to-deploy-TinyBlazorAdmin).
27+
👉 **[Step by Step Deployment](doc/how-to-deploy.md)** 👈 documentation is available here.
2728

28-
If you want to **Update** or **Upgrade**, please refer to [this page](https://github.com/microsoft/AzUrlShortener/wiki/How-to-Update---Upgrade) (wiki pages).
29+
If you want to **Update** or **Upgrade**, please refer to [the faq page](doc/faq.md).
2930

3031
## How To Use It
3132

32-
AzUrlShortener is an API that doesn't have any admin UI by default. There are many different ways to manage your Short Urls, from a direct HTTP call to a fancy website.
33+
Once deployed, use the admin webApp (aka TinyBlazorAdmin) to create new short URLs.
3334

34-
We suggest [Tiny Blazor Admin](./src/Cloud5mins.ShortenerTools.TinyBlazorAdmin/README.md); it's a static website.
35+
![Tiny Blazor Admin looks](images/tinyblazyadmin-tour.gif)
3536

36-
![Tiny Blazor Admin looks](/Media/TinyBlazorAdmin.gif)
3737

38-
By default, without any specific Admin tool, you can use an API client like [Postman](https://www.postman.com/) or a plugin to VSCode like [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client). We've included simple API calls via a postman collection and environment [here](./src/tools).
38+
### Alternative Admin Tool
3939

40-
You can also directly update the tables in storage using [Azure Storage Explorer](https://github.com/microsoft/AzUrlShortener/wiki/How-to-Use-Azure-Storage-Explorer-as-Admin-Tools-for-AzUrlShortener).
40+
By default, all the required resources are deployed into Azure. However you can decide to run the [API](src/Cloud5mins.ShortenerTools.Api/) locally, in a container or somewhere else. You can than use an API client like [Postman](https://www.postman.com/) or a plugin to VSCode like [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client), to manage your URLs. We've included simple API calls via a postman collection and environment [here](./src/tools/).
4141

42-
---
42+
You can also directly update the tables in storage using [Azure Storage Explorer](doc/how-to-use-azure-storage-explorer.md).
4343

44-
## How It Works
44+
---
4545

46-
If you are interested to learn more about what's under the hood, and get more details on each Azure Function, read the [How it works](https://github.com/microsoft/AzUrlShortener/wiki/how-it-works) page.
46+
## Videos
4747

4848
There is also a videos that explains a bit how things works and does a quick tour of the project.
4949

@@ -59,10 +59,9 @@ There is also a videos that explains a bit how things works and does a quick tou
5959

6060
We are always trying to make it better. See the [AzUrlShortener project](https://github.com/users/FBoucher/projects/6/views/4) page and [issues](https://github.com/microsoft/AzUrlShortener/issues) to see the current progress.
6161

62-
You are invited to go into the [Discussion](https://github.com/microsoft/AzUrlShortener/discussions) tab to share your feedback, ask question, and suggest new feature!
62+
You are invited to go into the [Discussion](https://github.com/microsoft/AzUrlShortener/discussions) tab to share your feedback, ask question, and suggest new feature! Or have look at our [faq](doc/faq.md) page for more information.
6363

6464
Current Backlog contains:
65-
- A deployment option with everything combined into TinyBlazorAdmin
6665
- More Statistics
6766
- QR Code
6867
- More tracking information (like Country)

doc/faq.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Frequently asked questions (f.a.q.)
2+
3+
- [How to Add a Custom Domain](./how-to-add-custom-domain.md)
4+
- [Add authentication to the admin website](./how-to-deploy.md#add-authentication-to-the-admin-website)
5+
- [Add a custom domain to the admin website](./how-to-add-custom-domain.md#add-a-custom-domain-to-the-admin-website)
6+
- [How to migrate your data](./how-to-migrate-data.md)
7+
- [How to deploy your AzUrlShortener](./how-to-deploy.md)
8+
- [How to run AzUrlShortener locally](#how-to-run-azurlshortener-locally)
9+
- [How to update/ redeploy AzUrlShortener](#update-redeploy-azurlshortener)
10+
- [How does it work?](./how-it-works.md)
11+
- [Security Considerations](./security-considerations.md)
12+
13+
14+
## How to run AzUrlShortener locally
15+
16+
You will need .NET 9, Docker or Podman installed on your machine. From the `scr` directory, run the following command `dotnet run --project Cloud5mins.ShortenerTools.AppHost`. You can also open the solution in Visual Studio or Visual studio Code and use F5, make sure the `Cloud5mins.ShortenerTools.AppHost` project is set as starting project.
17+
18+
19+
## Update/ redeploy AzUrlShortener
20+
21+
In a terminal, navigate to the `src` directory of your project.
22+
23+
```bash
24+
cd src
25+
```
26+
27+
To avoid affecting custom domains when deploying Azure Container Apps use the following command.
28+
29+
```bash
30+
azd config set alpha.aca.persistDomains on
31+
```
32+
33+
If you haven't already, log in to your Azure account with azd auth login. You can re-deploy the application with the following command:
34+
35+
```bash
36+
azd up
37+
```

doc/how-it-works.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
How It Works
2+
============
3+
4+
The backend is using Azure Functions and Azure Table Storable this page will explains how they work together in this tool.
5+
6+
![Global Diagram](../images/global_diagram_idea_v3b.jpg)
7+
8+
## Azure Functions
9+
10+
Azure Functions were the perfect match for this project because when you use a dynamic plan you are charged only when the function is running. In our case, it's only a few seconds at the time. To know more read [Azure Function Pricing](https://azure.microsoft.com/en-us/pricing/details/functions/)
11+
12+
### Function: UrlRedirect
13+
14+
This function returns a HTTP Redirect to the URL. You can call it directly doing an HTTP request of type POST or GET passing the vanity at the end of the URL. The Azure Function Proxy will call Function passing the parameter.
15+
16+
For example, if the domain is *c5m.ca* and the vanity is "project", the request `c5m.ca/2w` will call "UrlRedirect/{shortUrl}" where `shortUrl` is equal to "project". end the result will be a redirect to the long URL save in the storage.
17+
18+
Every time the Azure Function is called it will increment the click count and save the timestamp when this call appends.
19+
20+
## Azure Table Storage
21+
22+
The [Azure table storage](https://docs.microsoft.com/en-us/azure/storage/tables/) are the data store in this project. They are a very convenient service to keep structured NoSQL data in the cloud. They are also typically lower in cost than traditional SQL for similar volumes of data.
23+
24+
You can explore the Azure Table storage from Azure portal or using the [Azure Storage Explorer](https://docs.microsoft.com/en-us/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows#overview) it's a nice free tool that is available on all platforms (MacOS, Linux, Windows).
25+
26+
There are two tables that will be automatically created at the first call.
27+
28+
### Table: ClickStats
29+
30+
The ClickStats table get a new entry at every call of the Azure Function **UrlRedirect** with the Datetime value.
31+
32+
33+
### Table: UrlDetails
34+
35+
The UrlDetails table has the information about all the URLs created. The Vanity, URL, and number of clicks.
36+
37+
## Security Considerations
38+
39+
Review [Security Considerations](./security-considerations.md) and choose and implement an appropriate authorization approach.

doc/how-to-add-custom-domain.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# How to Add a Custom Domain
2+
3+
From the Azure Portal, Open the Azure COntainer Apps named `azfunc-light`. This is the one doing the redirect, this is where you want yout custom domain to be used.
4+
5+
From the left menu, select **Custom domains** and click on **Add custom domain**.
6+
7+
![Add custom domain](../images/add-custom-domain.png)
8+
9+
Follow the instructions to add your custom domain. Note that it may takes a few minutes for the domain to all be setup. Once it is, you should see the domain listed in the custom domains list withthe green check mark.
10+
11+
12+
## Add a custom domain to the admin website
13+
14+
To make it easier to find the TinyBlazorAdmin website, you can also add a custom domain to it. From your Domain provider (GoDaddy, NameCheap, etc.), you can set a forwarding subdomain to the admin website. For example, if you want to use `admin.yourdomain.com`, you can set a forwarding rule to the URL of the admin website (e.g., `https://admin-azfunc-light.azurecontainerapps.io`). This way, you can access the TinyBlazorAdmin website using your custom domain.
15+

doc/how-to-deploy.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# How to deploy your AzUrlShortener
2+
3+
## First thing first
4+
5+
### 👉 **Fork this repository** into your own account
6+
7+
> To Fork GitHub repository click on the Fork button on the top right of the screen.
8+
9+
![Click on the button Fork](../images/click-fork.png)
10+
11+
Provide a name. It can be anything, it just needs to be unique in your account (you can keep AzUrlShortener if you want). Add a description it you want and click the button **Create repository from template**.
12+
13+
![Give it a name description and click Create](../images/fork-details.png)
14+
15+
After a few seconds, you should now be in your version of the AzUrlShortener project. If you need more detail have a look to this GitHub doc: [Fork a repo](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo).
16+
17+
> Make sure you are currently in YOUR GitHub repository.
18+
>
19+
>![This should be YOUR repo](../images/your-account.png)
20+
21+
22+
## Prerequisites
23+
24+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) or [Podman](https://podman.io/getting-started/installation)
25+
- [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd)
26+
27+
28+
## Deploying to Azure
29+
30+
1. In a terminal, navigate to the `src` directory of your project.
31+
32+
```bash
33+
cd src
34+
```
35+
1. If you haven't already, log in to your Azure account with `azd auth login`.
36+
1. To avoid affecting custom domains when deploying Azure Container Apps use the following command. This mostly useful if you are re-deploying, or updating an existing application. If you don't have any custom domain assign to the Azure Container Apps, you can still execute the command, but it's optional.
37+
38+
```bash
39+
azd config set alpha.aca.persistDomains on
40+
```
41+
42+
1. Provision all required Azure resources and deploy the application with the following command:
43+
44+
```bash
45+
azd up
46+
```
47+
48+
1. Get the application URL
49+
50+
After the deployment is complete, you will see the URLs of your applications in the terminal; the one starting by `https://admin` is the admin tools (aka TinyBlazorAdmin), and the one starting with `https://azfunc-light` is the redicrect service. There is also many details about the resources created in Azure, and a link to the .NET Aspire dashboard.
51+
52+
![azd deployment result](../images/deployment-result.png)
53+
54+
## Add authentication to the admin website
55+
56+
The app is now deployed, but it does not have authentication enabled. Navigate to the [Azure Portal](https://portal.azure.com/), and find the Resource Group you just deployed (e.g., rg-azUrl-dev). From there, select the Container App named **admin**.
57+
58+
![select the Container App admin](../images/select-admin-container-app.png)
59+
60+
From the left menu, select **Authentication** and click **Add identity provider**.
61+
62+
![select Authentication](../images/auth-and-provider.png)
63+
64+
You can choose between multiple providers, but let's use Microsoft since it's deployed in Azure and you are already logged in. Once Microsoft is chosen, you will see many configuration options. Select the recommended client secret expiration (e.g., 180 days).
65+
66+
You can keep all the other default settings. Click **Add**. After a few seconds, you should see a notification in the top right corner that the identity provider was added successfully.
67+
68+
Voila! Your app now has authentication.
69+
70+
Next time you navigate to the app, you will be prompted to log in with your Microsoft account. Notice that your entire app is protected. No page is accessible without authentication.
71+
72+
The first time you log in, you will see a Permissions requested screen. Check the **Consent** checkbox, and click **Accept**.

doc/how-to-migrate-data.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# How to migrate your data
2+
3+
The easiest way to migrate your data between account or from an ealier version of AzUrlShortener is to use the **Azure Storage Explorer** to export the data as a CSV files and then import it into the new account or version.
4+
5+
Azure Storage Explorer is a free tool to manage your Azure cloud storage resources (aka your short URLs) from your desktop. It’s a cross-platform and can be downloaded [here](https://azure.microsoft.com/en-us/products/storage/storage-explorer/).
6+
7+
In the resources deployed to Azure there will be 2 storage accounts. One for the redirect service (azfunc-light) and one acting as the data store. That last one is the one you want to use for the data migration. The name of that storage account should start wirh `urldata`.
8+
9+
You need to expot to CSV the following tables:
10+
- UrlsDetails: This table contains the details of the short URLs, including the original URL, the short URL, schedules, etc.
11+
- ClickStats: This table contains the clicks informations.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Azure Storage Explorer is a free tool to manage your Azure cloud storage resources (aka your short URLs) from your desktop. It’s a cross-platform and can be downloaded [here](https://azure.microsoft.com/en-us/products/storage/storage-explorer/).
2+
3+
Once installed, you need to configure it to access your Azure account. You can do this by clicking on the Open connection dialog the **DC plug** icon in the top left corner, then select the Azure Subscription option.
4+
5+
![Azure Storage Explorer, Open connection dialog](../images/storageexplorer-selectresource.png)
6+
7+
And follow the steps to login to your Azure account.
8+
9+
## Find the URLs Storage table
10+
11+
To find the table where the URLs data is saved, expend your subscription (with the key icon) in the tree view. Expand the Storage accounts, your account (probably starting by 'shortenertool' and ending with 'sa'), tables, and finally look for. `UrlsDetails`
12+
13+
![Finding the UrlsDetails table in Azure Storage Explorer](../images/storageexplorer-tree.png)
14+
15+
Pro tip: You can right-click on the table and select `Pin to Quick Access` to create a shortcut to it.
16+
17+
## Create a new Short URL
18+
19+
To create a new URL, make sure the `UrlsDetails` table is selected (directly or using the quick access), then click on the **+ Add** button in the top menu.
20+
21+
![Creating a new URL in Azure Storage Explorer](../images/storageexplorer-addentry.png)
22+
23+
The *Add Entity* dialog window will open, You will need to fill it in order to create the URL.
24+
25+
- **Partition key:** (Required) This MUST be the first character of your short URL (aka RowKey).
26+
- **RowKey:** (Required) The short URL.
27+
- **Id:** Never set any value in this field, this is used by the system and URLs don’t need then.
28+
- **Clicks:** Don’t set any value in this field, it will be incremented automatically when your short URL is used.
29+
- **Url:** (Required) The original (aka long) URL.
30+
- **Title:** (Optional) This is for your convenience. Write something that helps you understand what the URL is from.
31+
- **Is Archived:** Since we create a new URL leaves that field empty.
32+
33+
> Alternatively, you could only add the properties: Partition key, RowKey, and the Url redirect will still work.
34+
35+
Once you are done, click on the **Insert** button. Congratulations, you have created a new URL, you can test it to be sure.
36+
37+
## Update an existing Short URL
38+
39+
First, we need to search for the URL that we want to edit, and we do this by executing a query.
40+
41+
![Execute a query in Azure Storage Explorer](../images/storageexplorer-updateexisting.png)
42+
43+
Click on the `Query` button in the top menu. Now depending on the information, you have changed the search parameters.
44+
45+
Use the RowKey if you have the `vanity` (the end of the short URL), and set the PartitionKey equal to the first character of that vanity.
46+
47+
If you want to search with by Title, like in the screenshot, change one of the fields by `Title` and remove the other by clicking on the “X” button on the left of the row.
48+
49+
> Note: There is no wildcard search in Azure Storage Explorer, so you need to use the exact value.
50+
51+
Once you are ready, click on the triangle (play) button, to execute your query. If you did it correctly, you will see the URL you are looking for. You can click the **Edit** button, or double-click the result row to edit it.
52+
53+
54+
You are invited to go into the [Discussion](https://github.com/microsoft/AzUrlShortener/discussions) tab to share your feedback, ask questions, and suggest new features!
55+

0 commit comments

Comments
 (0)