Skip to content

Commit 301e825

Browse files
lechnerc77kzhenmarcduikerBa4besdependabot[bot]
authored
Blob trigger and bindings lesson (TypeScript) (#53)
* typescript blob - wo tour * Added code tour, fixed typos * Code Tour - headers for homework * Fix broken link (#54) * Add CoudeTour Watch action * Try fix path to tours * Add workflow_dispatch to allow manual trigger of this action (#57) * Add workflow_dispatch to allow manual trigger of this action * Try to fix path * Add path for dotnet http only (#58) * Add path for dotnet http only * Append / * Remove explicit permissions * Append final .tours section * Bug fixes for the PowerShell lesson (#59) * Initial commit * Add PowerShell * net core > PowerShell * Remove incorrect observation * merge * change $Request to $Person, as it is in the lesson * Change $Request to $Person * Fix links * Fix link * Update CodeTourWatch that supports subfolders * Check if the new CodeTour watch forks (#60) * Update dependencies * Add Azurite * Update to new namespace * Use empty azurite location to users can choose their own location * Add azurite as recommendation * Rename dotnet to dotnetcore31 (#63) * Add action to build dotnetcore31 projects & add dependabot (#66) * Add action to build HTTP project * Fix syntax * Fix syntax * Fix casing * Add builds for all dotnetcore projects * Add dependabot with 3 initial dotnetcore projects * Add path filter to dotnetcore31 builds * Fix workflows path * Fix path start * Bump Microsoft.NET.Sdk.Functions (#67) Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.7 to 3.0.13. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits) --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk.Functions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.NET.Sdk.Functions (#70) Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.7 to 3.0.13. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits) --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk.Functions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.Azure.WebJobs.Extensions.Storage (#69) Bumps [Microsoft.Azure.WebJobs.Extensions.Storage](https://github.com/Azure/azure-webjobs-sdk) from 4.0.3 to 4.0.4. - [Release notes](https://github.com/Azure/azure-webjobs-sdk/releases) - [Commits](Azure/azure-webjobs-sdk@storage-v4.0.3...storage-v4.0.4) --- updated-dependencies: - dependency-name: Microsoft.Azure.WebJobs.Extensions.Storage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Azure.Storage.Blobs in /src/dotnetcore31/AzureFunctions.Blob (#68) Bumps [Azure.Storage.Blobs](https://github.com/Azure/azure-sdk-for-net) from 12.6.0 to 12.9.1. - [Release notes](https://github.com/Azure/azure-sdk-for-net/releases) - [Commits](Azure/azure-sdk-for-net@Azure.Storage.Blobs_12.6.0...Azure.Storage.Blobs_12.9.1) --- updated-dependencies: - dependency-name: Azure.Storage.Blobs dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add dependabot config for remaining projects * Bump Microsoft.Azure.WebJobs.Extensions.Storage (#71) Bumps [Microsoft.Azure.WebJobs.Extensions.Storage](https://github.com/Azure/azure-webjobs-sdk) from 4.0.3 to 4.0.4. - [Release notes](https://github.com/Azure/azure-webjobs-sdk/releases) - [Commits](Azure/azure-webjobs-sdk@storage-v4.0.3...storage-v4.0.4) --- updated-dependencies: - dependency-name: Microsoft.Azure.WebJobs.Extensions.Storage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.NET.Sdk.Functions (#72) Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.11 to 3.0.13. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits) --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk.Functions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marc Duiker <[email protected]> * Bump Microsoft.NET.Sdk.Functions (#73) Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.12 to 3.0.13. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits) --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk.Functions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Azure.Storage.Queues in /src/dotnetcore31/AzureFunctions.Queue (#75) Bumps [Azure.Storage.Queues](https://github.com/Azure/azure-sdk-for-net) from 12.6.1 to 12.7.0. - [Release notes](https://github.com/Azure/azure-sdk-for-net/releases) - [Commits](Azure/azure-sdk-for-net@Azure.Storage.Queues_12.6.1...Azure.Storage.Queues_12.7.0) --- updated-dependencies: - dependency-name: Azure.Storage.Queues dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marc Duiker <[email protected]> * Bump Microsoft.Azure.Cosmos in /src/dotnetcore31/AzureFunctions.Cosmos (#74) Bumps [Microsoft.Azure.Cosmos](https://github.com/Azure/azure-cosmos-dotnet-v3) from 3.16.0 to 3.20.0. - [Release notes](https://github.com/Azure/azure-cosmos-dotnet-v3/releases) - [Changelog](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md) - [Commits](Azure/azure-cosmos-dotnet-v3@3.16.0...3.20.0) --- updated-dependencies: - dependency-name: Microsoft.Azure.Cosmos dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.NET.Sdk.Functions (#76) Bumps [Microsoft.NET.Sdk.Functions](https://github.com/Azure/azure-functions-vs-build-sdk) from 3.0.11 to 3.0.13. - [Release notes](https://github.com/Azure/azure-functions-vs-build-sdk/releases) - [Commits](https://github.com/Azure/azure-functions-vs-build-sdk/commits) --- updated-dependencies: - dependency-name: Microsoft.NET.Sdk.Functions dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.Azure.WebJobs.Extensions.CosmosDB (#77) Bumps [Microsoft.Azure.WebJobs.Extensions.CosmosDB](https://github.com/Azure/azure-webjobs-sdk-extensions) from 3.0.9 to 3.0.10. - [Release notes](https://github.com/Azure/azure-webjobs-sdk-extensions/releases) - [Commits](Azure/azure-webjobs-sdk-extensions@http-v3.0.9...http-v3.0.10) --- updated-dependencies: - dependency-name: Microsoft.Azure.WebJobs.Extensions.CosmosDB dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Microsoft.Azure.WebJobs.Extensions.Storage (#78) Bumps [Microsoft.Azure.WebJobs.Extensions.Storage](https://github.com/Azure/azure-webjobs-sdk) from 4.0.3 to 4.0.4. - [Release notes](https://github.com/Azure/azure-webjobs-sdk/releases) - [Commits](Azure/azure-webjobs-sdk@storage-v4.0.3...storage-v4.0.4) --- updated-dependencies: - dependency-name: Microsoft.Azure.WebJobs.Extensions.Storage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add lychee link checker (#80) * Add lychee link checker * Add exclusion for local links and email (test data) * Exclude localhost * Exclude loopback * Add localhost regex :/ * Fix regex :'( * Fix argument formatting :'( * Fix formatting :'''( * Exclude lesson specific urls * Update job name to clarify purpose * Remove link local exclusion * switch to GitHub issue form (#81) * Bump Microsoft.Azure.Cosmos in /src/dotnetcore31/AzureFunctions.Cosmos (#82) Bumps [Microsoft.Azure.Cosmos](https://github.com/Azure/azure-cosmos-dotnet-v3) from 3.20.0 to 3.20.1. - [Release notes](https://github.com/Azure/azure-cosmos-dotnet-v3/releases) - [Changelog](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md) - [Commits](Azure/azure-cosmos-dotnet-v3@3.20.0...3.20.1) --- updated-dependencies: - dependency-name: Microsoft.Azure.Cosmos dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update links (#84) * typescript blob - wo tour * Added code tour, fixed typos * Code Tour - headers for homework * adjusted .gitignore +README * changing src file paths + adjustments Co-authored-by: Ken <[email protected]> Co-authored-by: Marc Duiker <[email protected]> Co-authored-by: Marc Duiker <[email protected]> Co-authored-by: Barbara 4bes <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 900b5a3 commit 301e825

File tree

66 files changed

+3234
-5
lines changed

Some content is hidden

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

66 files changed

+3234
-5
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
{
2+
"$schema": "https://aka.ms/codetour-schema",
3+
"title": "TypeScript Blob - 02. Using plain Blob output bindings",
4+
"steps": [
5+
{
6+
"title": "Overview",
7+
"description": "In this exercise, we will create a HTTP-triggered Function and extend it with a Blob _output binding_ in order to write a `Player` JSON object to a `players/out` path in the Blob storage.\r\n\r\nBefore you start, make sure that you have the Storage emulator up and running: \r\n>> azurite -s -l C:\\Users\\<Your_Name>\\azurite-storage -d C:\\Users\\<Your_Name>\\azurite-storage\\debug.log"
8+
},
9+
{
10+
"title": "Creation of Function App",
11+
"description": "Create a new HTTP Trigger Function App via the Azure Functions extension with the following settings:\r\n 1. Location: *AzureFunctions.Blob*\r\n 2. Language: *TypeScript*\r\n 3. Template: *HTTP trigger*\r\n 4. Function name: *StorePlayerWithBlobOutput*\r\n 5. AccessRights: *Function*\r\n\r\nAfter the Function App is created, execute \r\n\r\n>> npm install\r\n\r\nto install the required dependencies."
12+
},
13+
{
14+
"title": "Adjusting function.json - Restriction to POST requests",
15+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/function.json",
16+
"selection": {
17+
"start": {
18+
"line": 8,
19+
"character": 7
20+
},
21+
"end": {
22+
"line": 10,
23+
"character": 8
24+
}
25+
},
26+
"description": "We want to support POST requests only, so we remove the `\"get\"` from the array of support HTTP methods."
27+
},
28+
{
29+
"title": "Adjusting function.json - Adding the Blob output binding",
30+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/function.json",
31+
"selection": {
32+
"start": {
33+
"line": 12,
34+
"character": 5
35+
},
36+
"end": {
37+
"line": 17,
38+
"character": 7
39+
}
40+
},
41+
"description": "We add a new output binding that consists of the following parts:\r\n\r\n- The attribute `\"name\"` defines the name that we use to address the bound object in your `index.ts` file.\r\n- The attribute `\"type\"` specifies the binding type, in our case the Blob binding.\r\n- The attribute `\"path\"` tells the binding which path to use to store the blob. It consists of the name of the container (`player`), the directory (`out`) and the file name (`players/out/stored-input.json`).\r\n- The attribute `\"direction\"` defines the binding direction, in this case an output binding.\r\n"
42+
},
43+
{
44+
"title": "Adjusting the Function Code - Adding some basic variables",
45+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
46+
"selection": {
47+
"start": {
48+
"line": 9,
49+
"character": 1
50+
},
51+
"end": {
52+
"line": 11,
53+
"character": 1
54+
}
55+
},
56+
"description": "Next we implement the Azure Function to write the Blob.\r\n\r\nFirst we Add some variables for the HTTP response object namely for teh status code and the response message."
57+
},
58+
{
59+
"title": "Adjusting the Function Code - Adding decision logic if body was supplied",
60+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
61+
"selection": {
62+
"start": {
63+
"line": 12,
64+
"character": 5
65+
},
66+
"end": {
67+
"line": 12,
68+
"character": 20
69+
}
70+
},
71+
"description": "We must distinguish the cases if we receive a body in our POST request or not. So we have some basic `if-else` logic depending on the fact if a body was contained in the request.\r\n\r\n > 🔎 **Observation** - For the sake of this lesson, we leave out any further checks on the JSON object in the body of the request. In real life scenarios you certainly must place further validations in place to make sure that you store valid data."
72+
},
73+
{
74+
"title": "Adjusting the Function Code - Implementing the error case",
75+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
76+
"selection": {
77+
"start": {
78+
"line": 20,
79+
"character": 9
80+
},
81+
"end": {
82+
"line": 21,
83+
"character": 64
84+
}
85+
},
86+
"description": "When the request does not contain a body, we return the corresponding information to the caller."
87+
},
88+
{
89+
"title": "Adjusting the Function Code - Implementing the data transfer to the output binding",
90+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
91+
"selection": {
92+
"start": {
93+
"line": 14,
94+
"character": 9
95+
},
96+
"end": {
97+
"line": 14,
98+
"character": 47
99+
}
100+
},
101+
"description": "In case we receive a body we store the JSON body in the Blob storage. As we put in place the output binding, this is straightforward, as we just need to transfer the JSON object in the body to the binding available via the Function context."
102+
},
103+
{
104+
"title": "Adjusting the Function Code - Adding the response data for the success case",
105+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
106+
"selection": {
107+
"start": {
108+
"line": 16,
109+
"character": 8
110+
},
111+
"end": {
112+
"line": 17,
113+
"character": 65
114+
}
115+
},
116+
"description": "We complete the `if`-case by adding the corresponding response information, namely the status code and the response message."
117+
},
118+
{
119+
"title": "Adjusting the Function Code - Transferring data to the response object",
120+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
121+
"selection": {
122+
"start": {
123+
"line": 25,
124+
"character": 5
125+
},
126+
"end": {
127+
"line": 28,
128+
"character": 6
129+
}
130+
},
131+
"description": "Finally we add the response information in the corresponding object of the Function context."
132+
},
133+
{
134+
"title": "Local Configuration - Add Storage emulator",
135+
"file": "src/typescript/AzureFunctions.Blob/local.settings.json",
136+
"selection": {
137+
"start": {
138+
"line": 4,
139+
"character": 28
140+
},
141+
"end": {
142+
"line": 4,
143+
"character": 56
144+
}
145+
},
146+
"description": "Before we start the Function, we must configure that it uses the local storage emulator via the setting `\"UseDevelopmentStorage=true\"`."
147+
},
148+
{
149+
"title": "Start the Function",
150+
"file": "src/typescript/AzureFunctions.Blob/Exercise2PlainBlobOutputBindings/index.ts",
151+
"selection": {
152+
"start": {
153+
"line": 1,
154+
"character": 1
155+
},
156+
"end": {
157+
"line": 32,
158+
"character": 27
159+
}
160+
},
161+
"description": "Now it is time to start the Function (make sure that Azurite is up and running):\r\n \r\n 1. Install the dependencies first via \r\n>> npm install\r\n 2. Run the Function via \r\n>> npm run start\r\n"
162+
},
163+
{
164+
"title": "Execute the POST request",
165+
"file": "test/typescript/blob/bloboutput.http",
166+
"selection": {
167+
"start": {
168+
"line": 2,
169+
"character": 1
170+
},
171+
"end": {
172+
"line": 13,
173+
"character": 2
174+
}
175+
},
176+
"description": "Now call the Function via a POST request and check if something has been stored in your Blob storage."
177+
}
178+
]
179+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"$schema": "https://aka.ms/codetour-schema",
3+
"title": "TypeScript Blob - 03. Using binding expressions for Blob output bindings",
4+
"steps": [
5+
{
6+
"title": "Introduction",
7+
"description": "In this exercise, we will make use of _binding expressions_ to add a unique ID to the stored data and avoid the overwriting of entries."
8+
},
9+
{
10+
"title": "Adjusting function.json - Adding a binding expression",
11+
"file": "src/typescript/AzureFunctions.Blob/Exercise3BindingExpressionsForBlobOutputBindings/function.json",
12+
"selection": {
13+
"start": {
14+
"line": 15,
15+
"character": 7
16+
},
17+
"end": {
18+
"line": 15,
19+
"character": 59
20+
}
21+
},
22+
"description": "We adjust the `path` attribute in the `function.json` file via the `{rand-guid}` expression which is a so-called _binding expression_. The expression creates a random GUID when the output binding is executed by the Azure Functions runtime. There are more expressions available as described in the [documentation](https://docs.microsoft.com/azure/azure-functions/functions-bindings-expressions-patterns)."
23+
},
24+
{
25+
"title": "Start the Function",
26+
"file": "src/typescript/AzureFunctions.Blob/Exercise3BindingExpressionsForBlobOutputBindings/index.ts",
27+
"selection": {
28+
"start": {
29+
"line": 1,
30+
"character": 1
31+
},
32+
"end": {
33+
"line": 31,
34+
"character": 27
35+
}
36+
},
37+
"description": "We start the function via \r\n\r\n>> npm run start\r\n\r\nand check what impact the new configuration has. "
38+
},
39+
{
40+
"title": "Execute the POST requests",
41+
"file": "test/typescript/blob/bloboutput.http",
42+
"selection": {
43+
"start": {
44+
"line": 16,
45+
"character": 1
46+
},
47+
"end": {
48+
"line": 27,
49+
"character": 2
50+
}
51+
},
52+
"description": "Execute the POST request several times and check the names of the entries added in the Blob storage. "
53+
}
54+
]
55+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"$schema": "https://aka.ms/codetour-schema",
3+
"title": "TypeScript Blob - 04. Using payload data of trigger for Blob output bindings",
4+
"steps": [
5+
{
6+
"title": "Introduction",
7+
"description": "In this exercise, we making use of the data from the JSON body of the HTTP request to derive the file name we want to store.\r\n\r\nThe binding expression syntax enables us to use the attributes in the JSON file of our input, so we want to apply the following naming convention to our output file:\r\n\r\n```powershell\r\nplayers/out/stored-input-<GUID from the input>-<Nickname>-<Country in Location>.json\r\n```"
8+
},
9+
{
10+
"title": "Adjusting function.json - Referencing data from input binding",
11+
"file": "src/typescript/AzureFunctions.Blob/Exercise4PayloadDataOfTriggerForBlobOutputBindings/function.json",
12+
"selection": {
13+
"start": {
14+
"line": 15,
15+
"character": 7
16+
},
17+
"end": {
18+
"line": 15,
19+
"character": 82
20+
}
21+
},
22+
"description": "We adjust the `path` attribute in the `function.json`. We use the binding expression to reference fields fromthe JSON body of our incoming HTTP request.\r\n\r\n> 🔎 **Observation** - We can access nested structures of the JSON body via _dot notation_."
23+
},
24+
{
25+
"title": "Adjusting the Function Code - Refinement of the response message",
26+
"file": "src/typescript/AzureFunctions.Blob/Exercise4PayloadDataOfTriggerForBlobOutputBindings/index.ts",
27+
"selection": {
28+
"start": {
29+
"line": 16,
30+
"character": 9
31+
},
32+
"end": {
33+
"line": 16,
34+
"character": 92
35+
}
36+
},
37+
"description": "We changed the return message for the success case in the `index.ts` in order to be able to check if the GUID of the request object is used."
38+
},
39+
{
40+
"title": "Start the Function",
41+
"file": "src/typescript/AzureFunctions.Blob/Exercise4PayloadDataOfTriggerForBlobOutputBindings/index.ts",
42+
"selection": {
43+
"start": {
44+
"line": 1,
45+
"character": 1
46+
},
47+
"end": {
48+
"line": 31,
49+
"character": 27
50+
}
51+
},
52+
"description": "Strat the Function via\r\n\r\n>> npm run start"
53+
},
54+
{
55+
"title": "Execute the POST request",
56+
"file": "test/typescript/blob/bloboutput.http",
57+
"selection": {
58+
"start": {
59+
"line": 31,
60+
"character": 1
61+
},
62+
"end": {
63+
"line": 42,
64+
"character": 8
65+
}
66+
},
67+
"description": "Send a POST request and check the effects of the changed configuration in your Storage Explorer"
68+
}
69+
]
70+
}

0 commit comments

Comments
 (0)