Skip to content

Commit 8ffa415

Browse files
authored
Merge pull request #48797 from diberry/diberry/0121-signalr-functions-update
Fn + SignalR - updates
2 parents 99b31e2 + c777bca commit 8ffa415

12 files changed

+33
-36
lines changed

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/1-introduction.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Introduction
77
description: Learn to update an application to implement automatic updates that are nearly instantaneous.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/2-analyze-limitations-of-polling-in-a-web-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Analyze the limitations of a polling-based web app
77
description: Discuss the drawbacks of a web application that relies on polling to keep the UI updated.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/3-exercise-analyze-limitations-of-polling-in-a-web-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Exercise - Analyze the limitations of a polling-based web app
77
description: Review the implementation of polling website and run the app on your machine.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/4-enable-automatic-updates-in-a-web-app-using-signalr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Enable automatic updates in a web application using SignalR Service
77
description: Learn how a push-based architecture can make a better performing application.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/5-exercise-enable-automatic-updates-in-a-web-app-using-signalr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Exercise – Enable automatic updates in a web application using SignalR Service
77
description: Implement integration with Azure Functions and SignalR Service for fast and targeted automatic updates.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/6-host-a-static-website-using-a-storage-account.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Use a storage account to host a static website
77
description: Learn how an Azure Storage account is able to host static files over a secure server.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/7-exercise-host-a-static-website-using-a-storage-account.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Exercise - Use a storage account to host a static website
77
description: Customize your storage account, publish your function app and view your application hosted in the cloud.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/8-summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
prefetch-feature-rollout: true
66
title: Summary
77
description: Review changes made to your application that removed polling and added server push technologies.
8-
ms.date: 08/12/2024
8+
ms.date: 01/22/2025
99
author: craigshoemaker
1010
ms.author: cshoe
1111
ms.topic: unit

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/includes/3-exercise-analyze-limitations-of-polling-in-a-web-app.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ Before you change the prototype, you need to run it to validate the assumptions.
44

55
1. In a separate browser tab or window, fork the sample repository on GitHub with the following link: [mslearn-advocates.azure-functions-and-signalr](https://github.com/MicrosoftDocs/mslearn-advocates.azure-functions-and-signalr/fork). This allows you to push your changes to your own version of the source code. This is a required step in order to deploy the source code to Azure later in the module.
66

7-
1. In the terminal, clone the repository. In the following command, replace `MicrosoftDocs` with your account:
7+
1. In the terminal, clone your forked repository. In the following command, replace `MicrosoftDocs` with your account:
88

99
```bash
10-
git clone https://github.com/MicrosoftDocs/mslearn-advocates.azure-functions-and-signalr stock-prototype
10+
git clone https://github.com/<YOUR-GITHUB-ALIAS>/mslearn-advocates.azure-functions-and-signalr stock-prototype
1111
```
1212

1313
1. Install the dependencies in the **setup-resources** folder.
1414

1515
```bash
16-
cd stock-prototype/setup-resources && npm install
16+
cd setup-resources && npm install
1717
```
1818

1919
If you receive warnings about `EBADENGINE`, you can ignore them.
@@ -56,12 +56,21 @@ Before you change the prototype, you need to run it to validate the assumptions.
5656
|Azure Storage|Referred to as STORAGE_CONNECTION_STRING|
5757
|Resource Group|Referred to as RESOURCE_GROUP_NAME.|
5858
59-
1. Use a Node.js script to upload sample data into the database with the following command.
59+
1. At the terminal, still in the `setup-resources` directory, use a Node.js script to upload sample data into the database with the following command.
6060
6161
```bash
6262
npm start
6363
```
6464
65+
The output shows the starting data for the fictitious stock application:
66+
67+
```console
68+
Seed data added. Symbol ABC
69+
Seed data added. Symbol DEF
70+
Seed data added. Symbol GHI
71+
```
72+
73+
6574
1. In the terminal, navigate to the **root** folder.
6675
6776
```bash
@@ -152,6 +161,6 @@ BACKEND_URL=http://localhost:7071
152161
153162
:::image type="content" source="../media/visual-studio-code-terminal-output-stock-change.png" alt-text="Screenshot of Visual Studio Code terminal showing console output of the stock price change.":::
154163
155-
1. In both the start-client and start server terminals, stop the applications with <kbd>Ctrl</kbd> + <kbd>C</kbd> or kill the terminal by selecting the trashcan icon.
164+
1. In both the terminals for client and server, stop the applications with <kbd>Ctrl</kbd> + <kbd>C</kbd> or kill the terminal by selecting the trashcan icon.
156165
157166
In this unit, you ran the prototype. While the client does run successfully, it isn't efficient. While each individual client may not notice this with such a small number of stocks, that will change as the number of stocks grows and the number of clients pull from the server. The prototype can be improved. Let's learn how in the next unit.

learn-pr/advocates/automatic-update-of-a-webapp-using-azure-functions-and-signalr/includes/5-exercise-enable-automatic-updates-in-a-web-app-using-signalr.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You need to create an Azure SignalR resource.
1212
1. Navigate to the `setup-resources` subdirectory to create the resource.
1313

1414
```bash
15-
cd stock-prototype/setup-resources && bash create-signalr-resources.sh & cd ..
15+
cd setup-resources && bash create-signalr-resources.sh & cd ..
1616
```
1717

1818
1. Copy the connection string for the SignalR resource. You'll need this to update the server code.
@@ -85,10 +85,10 @@ The web client uses the SignalR client SDK to establish a connection to the serv
8585
```bash
8686
git add .
8787
git commit -m "Add SignalR functions"
88-
git push
88+
git push origin main
8989
```
9090
91-
## Create the `signalr-send-message` function
91+
## Create the Azure Functions app
9292
9393
Create a function app and related resources in Azure to which you can publish the new functions code.
9494
@@ -97,14 +97,15 @@ Create a function app and related resources in Azure to which you can publish th
9797
9898
| Name | Value |
9999
| -------------------------------------- | ------------------------------ |
100+
| Hosting | Select **Consumption Plan**.|
100101
| Resource group | Create a new resource group names `stock-prototype`.|
101102
| Function App name | Postpend your name to `api`. For example, `api-jamie`.|
102103
| Code or container | Select **code**. |
103104
| Runtime stack | Select **Node.js**. |
104105
| Version | Select an LTS version of Node.js. |
105106
| Region | Select a region close to you. |
106107
| Operating System | Select **Linux**.|
107-
| Hosting | Select **Consumption Plan**.|
108+
108109
109110
1. Don't fill out any other tabs and select **Review + create** then select **Create**. Wait for the deployment to complete before continuing.
110111
1. Select **Go to resource** to open the new function app.
@@ -122,25 +123,13 @@ Connect your new function app to the GitHub repository to enable continuous depl
122123
| Organization | Select your GitHub account. |
123124
| Repository | Search for and select `mslearn-advocates.azure-functions-and-signalr`. |
124125
| Branch | Select the **main** branch. |
125-
| Workflow Option| Select **Add a workflow ...**.|
126126
| Authentication type | Select **User-assigned-identity**.|
127127
| Subscription | Select the same subscription as seen at the top of the page. |
128128
| Identity | Select **Create new**.|
129129

130130
1. Select **Save** at the top of the section to save the settings. This creates a new workflow file in your forked repository.
131131
1. This deployment configuration creates a GitHub Actions workflow file in the repository. You need to update the workflow file to use the correct package path for the function app.
132132

133-
<!--- Remove this content section after the OIDC subject bug gets fixed by the Functions folks -->
134-
At this point, your GitHub deployment might generate an error because of a wrong configuration in the user-assigned managed identity created in your resource group in Azure.
135-
136-
## Update the managed identity
137-
138-
1. In your new function app page in the Azure portal, select your resource group in **Overview** > **Essentials**, then select the managed identity under **Resources**. This managed identity was created by Functions when you enabled the GitHub deployment.
139-
1. In the **Managed Identity** page, select **Settings** > **Federated credentials** and then select the existing credential.
140-
1. In **Connect your Github account**, change the setting for **Entity** to **Environment** and enter `Production` for **Environment**.
141-
1. Select **Update** to update the credential.
142-
<!--- end removal section -->
143-
144133
## Edit GitHub deployment workflow
145134

146135
1. In Visual Studio Code terminal, pull down the new workflow file from your fork (origin).
@@ -175,14 +164,14 @@ At this point, your GitHub deployment might generate an error because of a wrong
175164
```bash
176165
git add .
177166
git commit -m "Update deployment workflow to use package path"
178-
git push
167+
git push origin main
179168
```
180169

181170
This change will trigger the workflow to run. You can watch the workflow from the **Actions** section of the fork on GitHub.
182171

183172
## Configure the environment variables for the API functions
184173

185-
1. In the Azure portal, locate your function app and select **Settings** > **Configuration** then select **New application setting**.
174+
1. In the Azure portal, locate your function app and select **Settings** > **Environment variables** then select **+ Add**.
186175
1. Enter the settings for the Cosmos DB and SignalR connection strings. You can find the values in the `local.settings.json` in the `start/server` folder.
187176

188177
| Name | Value |
@@ -194,9 +183,8 @@ At this point, your GitHub deployment might generate an error because of a wrong
194183

195184
## Test the deployment of the API Functions
196185

197-
1. In the Azure portal, select **Overview** and select **URL** to open the app in a browser.
198-
1. Copy the URL, you'll need that when you update the client `.env` file for the `BACKEND_URL` value when you work in Unit 7.
199-
1. Open the URL in a browser to test the API functions.
186+
1. In the Azure portal, select **Overview** and select **Default domain** to open the app in a browser to test the API functions.
200187
1. Append `/api/getStocks` to the URL in the browser and press **Enter**. You should see a JSON array with stock data.
188+
1. Copy the URL, you'll need that when you update the client `.env` file for the `BACKEND_URL` value when you work in Unit 7.
201189
202190
You've updated the server code to return stocks with SignalR and you've deployed to a function app. Next, you'll update the client to use SignalR to receive updates.

0 commit comments

Comments
 (0)