Skip to content

Commit b3e44b3

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/azure-docs-pr into metadataupdatenetworkwatcher-batch3
2 parents 765303c + 6a75169 commit b3e44b3

29 files changed

+545
-208
lines changed

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6861,6 +6861,11 @@
68616861
"redirect_url": "/azure/azure-functions/functions-create-vnet",
68626862
"redirect_document_id": false
68636863
},
6864+
{
6865+
"source_path": "articles/azure-functions/create-cli.md",
6866+
"redirect_url": "/azure/azure-functions/functions-create-first-azure-function-azure-cli",
6867+
"redirect_document_id": false
6868+
},
68646869
{
68656870
"source_path": "articles/azure-functions/create-visual-studio.md",
68666871
"redirect_url": "/azure/azure-functions/functions-create-your-first-function-visual-studio",

articles/azure-functions/TOC.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,25 @@
1313
- name: Quickstarts
1414
expanded: true
1515
items:
16-
- name: Create function - C#
17-
href: functions-create-your-first-function-visual-studio.md
18-
- name: Create function - Java
19-
href: functions-create-first-java-maven.md
20-
- name: Create function - JavaScript
21-
href: functions-create-first-function-vs-code.md
22-
- name: Create function - PowerShell
23-
href: functions-create-first-function-powershell.md
24-
- name: Create function - Python
25-
href: functions-create-first-function-python.md
26-
- name: Connect to services
16+
- name: Create function
17+
expanded: true
18+
items:
19+
- name: Visual Studio Code
20+
href: /azure/azure-functions/functions-create-first-function-vs-code
21+
- name: Visual Studio
22+
href: functions-create-your-first-function-visual-studio.md
23+
- name: Command line
24+
href: functions-create-first-azure-function-azure-cli.md
25+
- name: Maven (Java)
26+
href: functions-create-first-java-maven.md
27+
- name: Connect to storage
2728
items:
28-
- name: Storage - C#
29+
- name: Visual Studio Code
30+
href: functions-add-output-binding-storage-queue-vs-code.md
31+
- name: Visual Studio
2932
href: functions-add-output-binding-storage-queue-vs.md
30-
- name: Storage - Java
33+
- name: Maven (Java)
3134
href: functions-add-output-binding-storage-queue-java.md
32-
- name: Storage - JavaScript
33-
href: functions-add-output-binding-storage-queue-vs-code.md
34-
- name: Storage - Python
35-
href: functions-add-output-binding-storage-queue-python.md
3635
- name: Tutorials
3736
items:
3837
- name: Functions with Logic Apps
@@ -160,7 +159,7 @@
160159
- name: Azure portal
161160
href: functions-create-first-azure-function.md
162161
- name: Command line
163-
href: functions-create-first-azure-function-azure-cli.md
162+
href: create-cli.md
164163
- name: Visual Studio
165164
href: create-visual-studio.md
166165
- name: Visual Studio Code

articles/azure-functions/durable/quickstart-js-vscode.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,31 @@ To complete this tutorial:
3434

3535
[!INCLUDE [functions-install-vs-code-extension](../../../includes/functions-install-vs-code-extension.md)]
3636

37-
[!INCLUDE [functions-create-function-app-vs-code](../../../includes/functions-create-function-app-vs-code.md)]
37+
## <a name="create-an-azure-functions-project"></a>Create your local project
38+
39+
In this section, you use Visual Studio Code to create a local Azure Functions project.
40+
41+
1. In Visual Studio Code, press F1 to open the command palette. In the command palette, search for and select `Azure Functions: Create new project...`.
42+
43+
1. Choose a directory location for your project workspace and choose **Select**.
44+
45+
> [!NOTE]
46+
> These steps were designed to be completed outside of a workspace. In this case, do not select a project folder that is part of a workspace.
47+
48+
1. Following the prompts, provide the following information for your desired language:
49+
50+
| Prompt | Value | Description |
51+
| ------ | ----- | ----------- |
52+
| Select a language for your function app project | JavaScript | Create a local Node.js Functions project. |
53+
| Select a version | Azure Functions v2 | You only see this option when the Core Tools aren't already installed. In this case, Core Tools are installed the first time you run the app. |
54+
| Select a template for your project's first function | HTTP trigger | Create an HTTP triggered function in the new function app. |
55+
| Provide a function name | HttpTrigger | Press Enter to use the default name. |
56+
| Authorization level | Function | The `function` authorization level requires you to supply an access key when calling your function's HTTP endpoint. This makes it more difficult to access an unsecured endpoint. To learn more, see [Authorization keys](../functions-bindings-http-webhook.md#authorization-keys). |
57+
| Select how you would like to open your project | Add to workspace | Creates the function app in the current workspace. |
58+
59+
Visual Studio Code installs the Azure Functions Core Tools, if needed. It also creates a function app project in a new workspace. This project contains the [host.json](../functions-host-json.md) and [local.settings.json](../functions-run-local.md#local-settings-file) configuration files. It also creates an HttpExample folder that contains the [function.json definition file](../functions-reference-node.md#folder-structure) and the [index.js file](../functions-reference-node.md#exporting-a-function), a Node.js file that contains the function code.
60+
61+
A package.json file is also created in the root folder.
3862

3963
## Install the Durable Functions npm package
4064

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

Lines changed: 132 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: Learn how to add an output binding to connect your functions to an
44
ms.date: 06/25/2019
55
ms.topic: quickstart
66
#Customer intent: As an Azure Functions developer, I want to connect my function to Azure Storage so that I can easily write data to a storage queue.
7+
zone_pivot_groups: programming-languages-set-functions
78
---
89

910
# Connect functions to Azure Storage using Visual Studio Code
@@ -19,8 +20,13 @@ Most bindings require a stored connection string that Functions uses to access t
1920
Before you start this article, you must meet the following requirements:
2021

2122
* Install the [Azure Storage extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurestorage).
23+
2224
* Install [Azure Storage Explorer](https://storageexplorer.com/). Storage Explorer is a tool you'll use to examine queue messages generated by your output binding. Storage Explorer is supported on macOS, Windows, and Linux-based operating systems.
23-
* Install [.NET Core CLI tools](https://docs.microsoft.com/dotnet/core/tools/?tabs=netcore2x) (C# projects only).
25+
26+
::: zone pivot="programming-language-csharp"
27+
* Install [.NET Core CLI tools](https://docs.microsoft.com/dotnet/core/tools/?tabs=netcore2x).
28+
::: zone-end
29+
2430
* Complete the steps in [part 1 of the Visual Studio Code quickstart](functions-create-first-function-vs-code.md).
2531

2632
This article assumes that you are already signed in to your Azure subscription from Visual Studio Code. You can sign in by running `Azure: Sign In` from the command palette.
@@ -42,50 +48,163 @@ In the [previous quickstart article](functions-create-first-function-vs-code.md)
4248

4349
Because you are using a Queue storage output binding, you must have the Storage bindings extension installed before you run the project.
4450

45-
# [JavaScript](#tab/nodejs)
51+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-python,programming-language-powershell"
4652

4753
[!INCLUDE [functions-extension-bundles](../../includes/functions-extension-bundles.md)]
4854

49-
# [C\#](#tab/csharp)
55+
::: zone-end
56+
57+
::: zone pivot="programming-language-csharp"
5058

5159
With the exception of HTTP and timer triggers, bindings are implemented as extension packages. Run the following [dotnet add package](/dotnet/core/tools/dotnet-add-package) command in the Terminal window to add the Storage extension package to your project.
5260

5361
```bash
5462
dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage --version 3.0.4
5563
```
56-
---
64+
65+
::: zone-end
66+
5767
Now, you can add the storage output binding to your project.
5868

5969
## Add an output binding
6070

6171
In Functions, each type of binding requires a `direction`, `type`, and a unique `name` to be defined in the function.json file. The way you define these attributes depends on the language of your function app.
6272

63-
# [JavaScript](#tab/nodejs)
73+
::: zone pivot="programming-language-javascript,programming-language-typescript,programming-language-python,programming-language-powershell"
6474

6575
[!INCLUDE [functions-add-output-binding-json](../../includes/functions-add-output-binding-json.md)]
6676

67-
# [C\#](#tab/csharp)
77+
::: zone-end
78+
79+
::: zone pivot="programming-language-csharp"
6880

6981
[!INCLUDE [functions-add-storage-binding-csharp-library](../../includes/functions-add-storage-binding-csharp-library.md)]
7082

71-
---
83+
::: zone-end
7284

7385
## Add code that uses the output binding
7486

7587
After the binding is defined, you can use the `name` of the binding to access it as an attribute in the function signature. By using an output binding, you don't have to use the Azure Storage SDK code for authentication, getting a queue reference, or writing data. The Functions runtime and queue output binding do those tasks for you.
7688

77-
# [JavaScript](#tab/nodejs)
89+
::: zone pivot="programming-language-javascript"
7890

7991
[!INCLUDE [functions-add-output-binding-js](../../includes/functions-add-output-binding-js.md)]
8092

81-
# [C\#](#tab/csharp)
93+
::: zone-end
94+
95+
::: zone pivot="programming-language-typescript"
96+
97+
Add code that uses the `msg` output binding object on `context.bindings` to create a queue message. Add this code before the `context.res` statement.
98+
99+
```typescript
100+
// Add a message to the Storage queue.
101+
context.bindings.msg = "Name passed to the function: " + name;
102+
```
103+
104+
At this point, your function should look as follows:
105+
106+
```javascript
107+
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
108+
109+
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
110+
context.log('HTTP trigger function processed a request.');
111+
const name = (req.query.name || (req.body && req.body.name));
112+
113+
if (name) {
114+
// Add a message to the Storage queue.
115+
context.bindings.msg = "Name passed to the function: " + name;
116+
// Send a "hello" response.
117+
context.res = {
118+
// status: 200, /* Defaults to 200 */
119+
body: "Hello " + (req.query.name || req.body.name)
120+
};
121+
}
122+
else {
123+
context.res = {
124+
status: 400,
125+
body: "Please pass a name on the query string or in the request body"
126+
};
127+
}
128+
};
129+
130+
export default httpTrigger;
131+
```
132+
133+
::: zone-end
134+
135+
::: zone pivot="programming-language-powershell"
136+
137+
Add code that uses the `Push-OutputBinding` cmdlet to write text to the queue using the `msg` output binding. Add this code before you set the OK status in the `if` statement.
138+
139+
```powershell
140+
# Write the $name value to the queue.
141+
$outputMsg = "Name passed to the function: $name"
142+
Push-OutputBinding -name msg -Value $outputMsg
143+
```
144+
145+
At this point, your function should look as follows:
146+
147+
```powershell
148+
using namespace System.Net
149+
150+
# Input bindings are passed in via param block.
151+
param($Request, $TriggerMetadata)
152+
153+
# Write to the Azure Functions log stream.
154+
Write-Host "PowerShell HTTP trigger function processed a request."
155+
156+
# Interact with query parameters or the body of the request.
157+
$name = $Request.Query.Name
158+
if (-not $name) {
159+
$name = $Request.Body.Name
160+
}
161+
162+
if ($name) {
163+
# Write the $name value to the queue.
164+
$outputMsg = "Name passed to the function: $name"
165+
Push-OutputBinding -name msg -Value $outputMsg
166+
167+
$status = [HttpStatusCode]::OK
168+
$body = "Hello $name"
169+
}
170+
else {
171+
$status = [HttpStatusCode]::BadRequest
172+
$body = "Please pass a name on the query string or in the request body."
173+
}
174+
175+
# Associate values to output bindings by calling 'Push-OutputBinding'.
176+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
177+
StatusCode = $status
178+
Body = $body
179+
})
180+
```
181+
182+
::: zone-end
183+
184+
::: zone pivot="programming-language-python"
185+
186+
[!INCLUDE [functions-add-output-binding-python](../../includes/functions-add-output-binding-python.md)]
187+
188+
::: zone-end
189+
190+
::: zone pivot="programming-language-csharp"
82191

83192
[!INCLUDE [functions-add-storage-binding-csharp-library-code](../../includes/functions-add-storage-binding-csharp-library-code.md)]
84193

85-
---
194+
::: zone-end
195+
196+
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-python"
86197

87198
[!INCLUDE [functions-run-function-test-local-vs-code](../../includes/functions-run-function-test-local-vs-code.md)]
88199

200+
::: zone-end
201+
202+
::: zone pivot="programming-language-powershell"
203+
204+
[!INCLUDE [functions-run-function-test-local-vs-code-ps](../../includes/functions-run-function-test-local-vs-code-ps.md)]
205+
206+
::: zone-end
207+
89208
A new queue named **outqueue** is created in your storage account by the Functions runtime when the output binding is first used. You'll use Storage Explorer to verify that the queue was created along with the new message.
90209

91210
### Connect Storage Explorer to your account
@@ -136,27 +255,13 @@ Now, it's time to republish the updated function app to Azure.
136255

137256
You created resources to complete these quickstarts. You may be billed for these resources, depending on your [account status](https://azure.microsoft.com/account/) and [service pricing](https://azure.microsoft.com/pricing/). If you don't need the resources anymore, here's how to delete them:
138257

139-
1. In Visual Studio Code, press F1 to open the command palette. In the command palette, search for and select `Azure Functions: Open in portal`.
140-
141-
1. Choose your function app, and press Enter. The function app page is opened in the [Azure portal](https://portal.azure.com).
142-
143-
1. In the **Overview** tab, select the named link under **Resource group**.
144-
145-
![Select the resource group to delete from the function app page.](./media/functions-add-output-binding-storage-queue-vs-code/functions-app-delete-resource-group.png)
146-
147-
1. In the **Resource group** page, review the list of included resources, and verify that they are the ones you want to delete.
148-
149-
1. Select **Delete resource group**, and follow the instructions.
150-
151-
Deletion may take a couple of minutes. When it's done, a notification appears for a few seconds. You can also select the bell icon at the top of the page to view the notification.
258+
[!INCLUDE [functions-cleanup-resources-vs-code.md](../../includes/functions-cleanup-resources-vs-code.md)]
152259

153260
## Next steps
154261

155-
You've updated your HTTP triggered function to write data to a Storage queue. To learn more about developing Functions, see [Develop Azure Functions using Visual Studio Code](functions-develop-vs-code.md).
156-
157-
Next, you should enable Application Insights monitoring for your function app:
262+
You've updated your HTTP triggered function to write data to a Storage queue. Next, you can learn more about developing Functions using Visual Studio Code:
158263
159264
> [!div class="nextstepaction"]
160-
> [Enable Application Insights integration](functions-monitoring.md#manually-connect-an-app-insights-resource)
265+
> [Develop Azure Functions using Visual Studio Code](functions-develop-vs-code.md)
161266
162267
[Azure Storage Explorer]: https://storageexplorer.com/

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,7 @@ The Azure Functions project template in Visual Studio Code creates a project tha
6262

6363
Visual Studio Code creates the PowerShell function app project in a new workspace. This project contains the [host.json](functions-host-json.md) and [local.settings.json](functions-run-local.md#local-settings-file) configuration files, which apply to all function in the project. This [PowerShell project](functions-reference-powershell.md#folder-structure) is the same as a function app running in Azure.
6464

65-
## Run the function locally
66-
67-
Azure Functions Core Tools integrates with Visual Studio Code to let you run and debug an Azure Functions project locally.
68-
69-
1. To debug your function, insert a call to the [`Wait-Debugger`] cmdlet in the function code before you want to attach the debugger, then press F5 to start the function app project and attach the debugger. Output from Core Tools is displayed in the **Terminal** panel.
70-
71-
1. In the **Terminal** panel, copy the URL endpoint of your HTTP-triggered function.
72-
73-
![Azure local output](./media/functions-create-first-function-powershell/functions-vscode-f5.png)
74-
75-
1. Append the query string `?name=<yourname>` to this URL, and then use `Invoke-RestMethod` to execute the request, as follows:
76-
77-
```powershell
78-
PS > Invoke-RestMethod -Method Get -Uri http://localhost:7071/api/HttpTrigger?name=PowerShell
79-
Hello PowerShell
80-
```
81-
82-
You can also execute the GET request from a browser.
83-
84-
When you call the HttpTrigger endpoint without passing a `name` parameter either as a query parameter or in the body, the function returns a [HttpStatusCode]::BadRequest error. When you review the code in run.ps1, you see that this error occurs by design.
85-
86-
1. To stop debugging, press Shift + F5.
87-
88-
After you've verified that the function runs correctly on your local computer, it's time to publish the project to Azure.
89-
90-
> [!NOTE]
91-
> Remember to remove any calls to `Wait-Debugger` before you publish your functions to Azure.
92-
>
93-
> Creating a function app in Azure only prompts for your function app name. Other values are defined for you.
94-
> Set `azureFunctions.advancedCreation` to `true` to be prompted for all other values.
65+
[!INCLUDE [functions-run-function-test-local-vs-code-ps](../../includes/functions-run-function-test-local-vs-code-ps.md)]
9566

9667
[!INCLUDE [functions-publish-project-vscode](../../includes/functions-publish-project-vscode.md)]
9768

0 commit comments

Comments
 (0)