Skip to content

Commit 0ef5128

Browse files
author
Glenn Gailey
committed
Kraig suggestions and cmd code added
1 parent 7baf1e4 commit 0ef5128

File tree

4 files changed

+37
-36
lines changed

4 files changed

+37
-36
lines changed

articles/azure-functions/functions-add-output-binding-storage-queue-cli.md

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -121,54 +121,37 @@ Observe that you *don't* need to write any code for authentication, getting a qu
121121
122122
## View the message in the Azure Storage queue
123123
124-
When your function generates an HTTP response for the web browser, it also calls `msg.set(name)`, which writes a message to an Azure Storage queue named `outqueue`, as specified in the queue binding. You can view the queue in the [Azure portal](../storage/queues/storage-quickstart-queues-portal.md) or in the [Microsoft Azure Storage Explorer](https://storageexplorer.com/). You can also view the queue in the Azure CLI as described in the following steps:
124+
You can view the queue in the [Azure portal](../storage/queues/storage-quickstart-queues-portal.md) or in the [Microsoft Azure Storage Explorer](https://storageexplorer.com/). You can also view the queue in the Azure CLI, as described in the following steps:
125125
126-
1. Open the function project's *local.setting.json* file and copy the connection string value. In a terminal or command window, run the following command to create an environment variable named `AZURE_STORAGE_CONNECTION_STRING`, pasting your specific connection string in place of `<connection_string>`. (This environment variable means you don't need to supply the connection string to each subsequent command using the `--connection-string` argument.)
126+
1. Open the function project's *local.setting.json* file and copy the connection string value. In a terminal or command window, run the following command to create an environment variable named `AZURE_STORAGE_CONNECTION_STRING`, pasting your specific connection string in place of `<MY_CONNECTION_STRING>`. (This environment variable means you don't need to supply the connection string to each subsequent command using the `--connection-string` argument.)
127127
128128
# [bash](#tab/bash)
129129
130130
```bash
131-
AZURE_STORAGE_CONNECTION_STRING="<connection_string>"
131+
AZURE_STORAGE_CONNECTION_STRING="<MY_CONNECTION_STRING>"
132132
```
133133
134134
# [PowerShell](#tab/powershell)
135135
136136
```powershell
137-
$env:AZURE_STORAGE_CONNECTION_STRING = "<connection_string>"
137+
$env:AZURE_STORAGE_CONNECTION_STRING = "<MY_CONNECTION_STRING>"
138138
```
139139
140140
# [Cmd](#tab/cmd)
141141
142142
```cmd
143-
set AZURE_STORAGE_CONNECTION_STRING="<connection_string>"
143+
set AZURE_STORAGE_CONNECTION_STRING="<MY_CONNECTION_STRING>"
144144
```
145145
146146
---
147147
148148
1. (Optional) Use the [`az storage queue list`](/cli/azure/storage/queue#az-storage-queue-list) command to view the Storage queues in your account. The output from this command should include a queue named `outqueue`, which was created when the function wrote its first message to that queue.
149149
150-
# [bash](#tab/bash)
151-
152-
```bash
153-
az storage queue list --output tsv
154-
```
155-
156-
# [PowerShell](#tab/powershell)
157-
158-
```powershell
159-
az storage queue list --output tsv
160-
```
161-
162-
# [Cmd](#tab/cmd)
163-
164-
```cmd
150+
```azure-cli
165151
az storage queue list --output tsv
166152
```
167-
168-
---
169153
170-
171-
1. Use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view the messages in this queue, which should be the first name you used when testing the function earlier. The command retrieves the first message in the queue in [base64 encoding](functions-bindings-storage-queue-trigger.md#encoding), so you must also decode the message to view as text.
154+
1. Use the [`az storage message peek`](/cli/azure/storage/message#az-storage-message-peek) command to view a message in this queue, which should be the first name you used when testing the function earlier. The command retrieves only the first message in the queue, which is [base64 encoded](functions-bindings-storage-queue-trigger.md#encoding), and decodes it to show the message text.
172155
173156
# [bash](#tab/bash)
174157
@@ -184,8 +167,12 @@ When your function generates an HTTP response for the web browser, it also calls
184167
185168
# [Cmd](#tab/cmd)
186169
187-
Because you need to dereference the message collection and decode from base64, run PowerShell and use the PowerShell command.
170+
```cmd
171+
az storage message peek --queue-name outqueue -o tsv --query [].{Message:content} > %TEMP%out.b64 && certutil -decode -f %TEMP%out.b64 %TEMP%out.txt > NUL && type %TEMP%out.txt && del %TEMP%out.b64 %TEMP%out.txt /q
172+
```
188173
174+
This script uses certutil to decode the base64-encoded message collection from a local temp file. If there's no output, try removing `> NUL` from the script and stop suppressing certutil message, in case there's an error.
175+
189176
---
190177
191178
## Redeploy the project to Azure
@@ -220,9 +207,7 @@ Now that you've tested the function locally and verified that it wrote a message
220207
221208
## Clean up resources
222209
223-
If you continue to the next step, [Enable Application Insights integration](functions-monitoring.md#manually-connect-an-app-insights-resource), keep all your resources in place as you'll build on what you've already done.
224-
225-
Otherwise, use the following command to delete the resource group and all its contained resources to avoid incurring further costs.
210+
After you've finished, use the following command to delete the resource group and all its contained resources to avoid incurring further costs.
226211
227212
```azurecli
228213
az group delete --name AzureFunctionsQuickstart-rg
@@ -232,27 +217,34 @@ az group delete --name AzureFunctionsQuickstart-rg
232217

233218
You've updated your HTTP triggered function to write data to a Storage queue. Now you can learn more about developing Functions from the command line using Core Tools and Azure CLI:
234219

235-
+ [Work with Azure Functions Core Tools](functions-run-local.md)
220+
+ [Work with Azure Functions Core Tools](functions-run-local.md)
236221
::: zone pivot="programming-language-csharp"
237222
+ [Examples of complete Function projects in C#](/samples/browse/?products=azure-functions&languages=csharp).
223+
238224
+ [Azure Functions C# developer reference](functions-dotnet-class-library.md)
239225
::: zone-end
240226
::: zone pivot="programming-language-javascript"
241227
+ [Examples of complete Function projects in JavaScript](/samples/browse/?products=azure-functions&languages=javascript).
228+
242229
+ [Azure Functions JavaScript developer guide](functions-reference-node.md)
243230
::: zone-end
244231
::: zone pivot="programming-language-typescript"
245232
+ [Examples of complete Function projects in TypeScript](/samples/browse/?products=azure-functions&languages=typescript).
233+
246234
+ [Azure Functions TypeScript developer guide](functions-reference-node.md#typescript)
247235
::: zone-end
248236
::: zone pivot="programming-language-python"
249237
+ [Examples of complete Function projects in Python](/samples/browse/?products=azure-functions&languages=python).
238+
250239
+ [Azure Functions Python developer guide](functions-reference-python.md)
251240
::: zone-end
252241
::: zone pivot="programming-language-powershell"
253242
+ [Examples of complete Function projects in PowerShell](/samples/browse/?products=azure-functions&languages=azurepowershell).
243+
254244
+ [Azure Functions PowerShell developer guide](functions-reference-powershell.md)
255245
::: zone-end
256246
+ [Azure Functions triggers and bindings](functions-triggers-bindings.md).
247+
257248
+ [Functions pricing page](https://azure.microsoft.com/pricing/details/functions/)
249+
258250
+ [Estimating Consumption plan costs](functions-consumption-costs.md) article.

articles/azure-functions/functions-create-first-azure-function-azure-cli.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ If you see the error, "Can't find app with name ...", wait a few seconds and try
318318
319319
The publish command shows results similar to the following output (truncated for simplicity):
320320
321-
```output
321+
<pre><code>
322+
...
323+
322324
Getting site publishing info...
323325
Creating archive for current directory...
324326
Performing remote build for functions project.
@@ -331,7 +333,7 @@ Syncing triggers...
331333
Functions in msdocs-azurefunctions-qs:
332334
HttpExample - [httpTrigger]
333335
Invoke url: https://msdocs-azurefunctions-qs.azurewebsites.net/api/httpexample?code=KYHrydo4GFe9y0000000qRgRJ8NdLFKpkakGJQfC3izYVidzzDN4gQ==
334-
```
336+
</code></pre>
335337
336338
## Invoke the function on Azure
337339

includes/functions-run-function-test-local-cli.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.author: glenga
88

99
## Run the function locally
1010

11-
Start the function by starting the local Azure Functions runtime host in the *LocalFunctionProj* folder:
11+
Run your function by starting the local Azure Functions runtime host from the *LocalFunctionProj* folder:
1212

1313
::: zone pivot="programming-language-csharp,programming-language-powershell,programming-language-javascript,programming-language-python"
1414
```
@@ -23,21 +23,28 @@ npm start
2323
```
2424
::: zone-end
2525

26-
The following output should appear. (If HttpExample doesn't appear as shown below, you likely started the host from within the *HttpExample* folder. In that case, use **Ctrl**+**C** to stop the host, navigate to the parent *LocalFunctionProj* folder, and run the previous command again.)
26+
Toward the end of the output, the following lines should appear:
27+
28+
<pre><code>
29+
...
2730

28-
```output
2931
Now listening on: http://0.0.0.0:7071
3032
Application started. Press Ctrl+C to shut down.
3133

3234
Http Functions:
3335

3436
HttpExample: [GET,POST] http://localhost:7071/api/HttpExample
35-
```
37+
...
38+
39+
</code></pre>
40+
41+
>[!NOTE]
42+
> If HttpExample doesn't appear as shown below, you likely started the host from within the *HttpExample* folder. In that case, use **Ctrl**+**C** to stop the host, navigate to the parent *LocalFunctionProj* folder, and run the previous command again.
3643
3744
Copy the URL of your `HttpExample` function from this output to a browser and append the query string `?name=<your-name>`, making the full URL like `http://localhost:7071/api/HttpExample?name=Functions`. The browser should display a message like `Hello Functions`:
3845

3946
![Result of the function run locally in the browser](./media/functions-run-function-test-local-cli/function-test-local-browser.png)
4047

4148
The terminal in which you ran `func start` also shows log output as you make requests.
4249

43-
When you're ready, use **Ctrl**+**C** to stop the functions host.
50+
When you're ready, use **Ctrl**+**C** and choose `y` to stop the functions host.
-2.16 KB
Loading

0 commit comments

Comments
 (0)