You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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",
"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",
"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",
"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",
"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",
"description": "Before we start the Function, we must configure that it uses the local storage emulator via the setting `\"UseDevelopmentStorage=true\"`."
"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."
"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",
"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)."
"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",
"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",
"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."
0 commit comments