Skip to content

Commit 23fdccb

Browse files
committed
Cleanup + Acrolinx
1 parent ace7603 commit 23fdccb

File tree

2 files changed

+47
-53
lines changed

2 files changed

+47
-53
lines changed

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

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Create functions in Azure using the Azure Developer CLI
33
description: "Learn how to use the Azure Developer CLI (azd) to create resources and deploy the local project to a Flex Consumption plan on Azure."
4-
ms.date: 08/21/2024
4+
ms.date: 08/27/2024
55
ms.topic: quickstart
66
zone_pivot_groups: programming-languages-set-functions
77
#Customer intent: As a developer, I need to know how to use the Azure Developer CLI to create and deploy my function code securely to a new function app in the Flex Consumption plan in Azure by using azd templates and the azd up command.
@@ -23,8 +23,6 @@ Because of the Flex Consumption plan, completing this quickstart incurs a small
2323

2424
+ [Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd).
2525

26-
+ [Azurite storage emulator](../storage/common/storage-use-azurite.md).
27-
2826
+ [Azure Functions Core Tools](functions-run-local.md#install-the-azure-functions-core-tools).
2927

3028
::: zone pivot="programming-language-csharp"
@@ -169,10 +167,7 @@ In the root folder, run these commands to create and activate a virtual environm
169167
### [Linux/macOS](#tab/linux)
170168
171169
```bash
172-
python -m venv .venv
173-
```
174-
175-
```bash
170+
python3 -m venv .venv
176171
source .venv/bin/activate
177172
```
178173

@@ -184,11 +179,8 @@ sudo apt-get install python3-venv
184179

185180
### [Windows](#tab/windows)
186181

187-
```cmd
182+
```shell
188183
py -m venv .venv
189-
```
190-
191-
```cmd
192184
.venv\scripts\activate
193185
```
194186

@@ -198,9 +190,7 @@ py -m venv .venv
198190

199191
## Run in your local environment
200192

201-
1. In a separate terminal or command prompt, start `azurite`. You need to use a separate terminal because the Azurite process blocks the thread while it runs.
202-
203-
1. Run this command in your project's root folder:
193+
1. Run this command from your project's root folder in a terminal or command prompt:
204194

205195
::: zone pivot="programming-language-csharp, programming-language-powershell,programming-language-python,programming-language-javascript"
206196
```command
@@ -229,13 +219,16 @@ py -m venv .venv
229219

230220
:::code language="http" source="~/functions-quickstart-dotnet-azd/FunctionHttp/test.http" range="5-11" :::
231221

232-
You can find examples of both HTTP requests in the _test.http_ project file
222+
You can find examples of both HTTP requests in the _test.http_ project file.
233223

234224
1. When you're done, press Ctrl+C in the terminal window to stop the `func.exe` host process.
225+
::: zone pivot="programming-language-python"
226+
5. Run `deactivate` to shut down the virtual environment.
227+
::: zone-end
235228
236229
## Review the code (optional)
237230
238-
If you choose to, review the code that defines the two HTTP trigger function endpoints:
231+
You can review the code that defines the two HTTP trigger function endpoints:
239232
240233
### [`httpget`](#tab/get)
241234
::: zone pivot="programming-language-csharp"
@@ -251,19 +244,19 @@ If you choose to, review the code that defines the two HTTP trigger function end
251244
:::code language="typescript" source="~/functions-quickstart-typescript-azd/src/functions/httpGetFunction.ts" :::
252245
::: zone-end
253246
::: zone pivot="programming-language-powershell"
254-
This code is the `function.json` file that defines the `httpget` function:
247+
This `function.json` file defines the `httpget` function:
255248
:::code language="json" source="~/functions-quickstart-powershell-azd/src/httpGetFunction/function.json" :::
256-
This is the `run.ps1` file that implements the function code:
249+
This `run.ps1` file implements the function code:
257250
:::code language="powershell" source="~/functions-quickstart-powershell-azd/src/httpGetFunction/run.ps1" :::
258251
::: zone-end
259252
::: zone pivot="programming-language-python"
260-
:::code language="python" source="~/functions-quickstart-python-azd/function_app.py" range="6-18" :::
253+
:::code language="python" source="~/functions-quickstart-python-azd/function_app.py" range="6-12" :::
261254
::: zone-end
262255
263256
### [`httppost`](#tab/post)
264257
265258
::: zone pivot="programming-language-csharp"
266-
:::code language="csharp" source="~/functions-quickstart-dotnet-azd/FunctionHttp/httpPostBodyFunction.cs" range="19-31":::
259+
:::code language="csharp" source="~/functions-quickstart-dotnet-azd/FunctionHttp/httpPostBodyFunction.cs" range="19-31":::
267260
::: zone-end
268261
::: zone pivot="programming-language-java"
269262
:::code language="java" source="~/functions-quickstart-java-azd/http/src/main/java/com/contoso/Function.java" range="44-71" :::
@@ -275,25 +268,25 @@ This is the `run.ps1` file that implements the function code:
275268
:::code language="typescript" source="~/functions-quickstart-typescript-azd/src/functions/httpPostBodyFunction.ts" :::
276269
::: zone-end
277270
::: zone pivot="programming-language-powershell"
278-
This is the `function.json` file that defines the `httppost` function:
271+
This `function.json` file defines the `httppost` function:
279272
:::code language="json" source="~/functions-quickstart-powershell-azd/src/httpPostBodyFunction/function.json" :::
280-
This is the `run.ps1` file that implements the function code:
273+
This `run.ps1` file implements the function code:
281274
:::code language="powershell" source="~/functions-quickstart-powershell-azd/src/httpPostBodyFunction/run.ps1" :::
282-
::: zone-end
275+
::: zone-end
283276
::: zone pivot="programming-language-python"
284-
:::code language="python" source="~/functions-quickstart-python-azd/function_app.py" range="20-40" :::
277+
:::code language="python" source="~/functions-quickstart-python-azd/function_app.py" range="14-34" :::
285278
::: zone-end
286279
287280
---
288281
289-
After you verified your functions run locally, it's time to publish them to Azure.
282+
After you verify your functions locally, it's time to publish them to Azure.
290283

291284
## Deploy to Azure
292285

293286
This project is configured to use the `azd up` command to deploy this project to a new function app in a Flex Consumption plan in Azure.
294287

295288
>[!TIP]
296-
>This project uses best practices for securing your app by running in a Flex consumption plan, using only managed identities instead of stored connection strings, and running in a virtual network.
289+
>This project includes a set of Bicep files that `azd` uses to create a best practices secure deployment to a Flex consumption plan.
297290

298291
1. Run this command to create the Azure resources and deploy your app to Azure.
299292

@@ -308,44 +301,41 @@ This project is configured to use the `azd up` command to deploy this project to
308301
+ _Azure subscription_: Subscription in which your resources are created.
309302
+ _Azure location_: Azure region in which to create the resource group that contains the new Azure resources. Only regions that currently support the Flex Consumption plan are shown.
310303

311-
The `azd up` command applies your response to these prompts to the Bicep configuration files and create Azure resources.
304+
The `azd up` command uses your response to these prompts with the Bicep configuration files to complete these deployment tasks:
312305

313-
306+
+ Create and configure these required Azure resources (equivalent to [`azd provision`](/azure/developer/azure-developer-cli/reference#azd-provision)):
314307

315-
these deployment tasks:
316-
317-
+ Create and configure all required Azure resources for secure deployment ([`azd provision`](/azure/developer/azure-developer-cli/reference#azd-provision)), which includes:
318-
* Flex Consumption plan and function app.
319-
* Azure Storage (required) and Application Insights (recommended).
320-
* Access policies and roles for your account.
321-
* Service-to-service connections using managed identities (instead of stored connection strings).
322-
* Virtual network to securely run both the function app and the other Azure resources.
323-
* Package and deploy your code to the deployment container ([`azd deploy`](/azure/developer/azure-developer-cli/reference#azd-deploy)).
324-
325-
1. Create the Azure resources required to host the project in a function app running in the Flex Consumption plan.
326-
1. Package and deploy this code project to the deployment container after the resources are provisioned. The app is then started and runs in the deployment container.
327-
328-
After the command completes successfully, you see links to the resources created.
329-
330-
Your responses to the prompts are stored, and you can run the `azd up` command as many times as you like to both provision and deploy updates to your application. During subsequent executions, existing resources are skipped, but deployed code files are always overwritten by the latest deployment package. Use the `azd env get-values` command to review all of the variables used when creating Azure resources.
308+
+ Flex Consumption plan and function app
309+
+ Azure Storage (required) and Application Insights (recommended)
310+
+ Access policies and roles for your account
311+
+ Service-to-service connections using managed identities (instead of stored connection strings)
312+
+ Virtual network to securely run both the function app and the other Azure resources
331313

314+
+ Package and deploy your code to the deployment container (equivalent to [`azd deploy`](/azure/developer/azure-developer-cli/reference#azd-deploy)). The app is then started and runs in the deployed package.
332315

316+
1. After the command completes successfully, you see links to the resources created. Make a copy of the **Function App** name. If you forgot to save the app name, you can always get it again using the `azd env get-values` command and copying `AZURE_FUNCTION_NAME`.
333317

334318
## Invoke the function on Azure
335319

336-
Because your function uses an HTTP trigger, you invoke it by making an HTTP request to its URL in the browser or with a tool like curl.
320+
You can now invoke your function endpoints in Azure by making HTTP requests to their URLs using your HTTP test tool or from the browser (for GET requests). When your functions run in Azure, access key authorization is enforced, and you must provide a function access key with your request.
337321

338-
1. From your HTTP test tool in a second terminal or from a browser, call the HTTP GET endpoint, which should look like this URL:
322+
You can use the Core Tools to obtain the URL endpoints of your functions running in Azure, along with their required access key values.
339323

340-
<http://localhost:7071/api/httpget>
324+
1. In your local terminal or command prompt, run this `func azure functionapp list-functions` command:
325+
326+
```command
327+
func azure functionapp list-functions <APP_NAME> --show-keys
328+
```
329+
330+
In this example, replace `<APP_NAME>` with the name of the function app created by azd during deployment. Using the `--show-keys` option means that the returned **Invoke URL:** value for each endpoint includes a function-level access key.
341331

342-
1. From your HTTP test tool in a second terminal, send an HTTP POST request like this example:
332+
1. As before, use your HTTP test tool to validate these URLs in your function app running in Azure.
343333

344-
:::code language="csharp" source="~/functions-quickstart-dotnet-azd/FunctionHttp/test.http" range="5-11":::
334+
## Redeploy your code
345335

346-
## Review Bicep files (optional)
336+
Your responses to `azd` prompts and other environment variables generated by `azd` are stored in your named environment. This means that you can run the `azd up` command as many times as you need to both reprovision your function app and deploy updates to your source code. During subsequent executions, existing resources are skipped. Deployed code files are always overwritten by the latest deployment package.
347337

348-
`<<to-do>>`
338+
Use the `azd env get-values` command to review all of the variables in your environment that were used when creating Azure resources.
349339

350340
## Clean up resources
351341

@@ -355,7 +345,11 @@ When you're done working with your function app and related resources, you can u
355345
azd down
356346
```
357347
358-
This command doesn't affect your source code repository. For more information about Functions costs, see [Estimating Flex Consumption plan costs](./flex-consumption-plan.md#billing).
348+
This command doesn't affect your local code project.
359349

360350
## Related content
361351

352+
+ [Flex Consumption plan](flex-consumption-plan.md)
353+
+ [Azure Developer CLI (azd)](/azure/developer/azure-developer-cli/)
354+
+ [Azure Functions Core Tools reference](functions-core-tools-reference.md)
355+
+ [Code and test Azure Functions locally](functions-develop-local.md)

includes/functions-quickstart-azd-env.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ ms.author: glenga
88

99
2. Enter an environment name when prompted, such as `flexquickstart`. In `azd`, the environment is used to maintain a unique deployment context for your app, and you can define more than one. It's also used in the name of the resource group you create in Azure.
1010

11-
After you specify the environment, `azd` clones the template files to your machine and initializes a local project.
11+
After you specify the environment, `azd` clones the template files to your machine and initializes a local project in your current folder.

0 commit comments

Comments
 (0)