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
Copy file name to clipboardExpand all lines: articles/azure-functions/how-to-create-function-azure-cli.md
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,38 +28,40 @@ Before you begin, you must have the following:
28
28
## Create a local function project and function
29
29
30
30
In Azure Functions, a function project is a container for one or more individual functions that each responds to a specific trigger. All functions in a project share the same local and hosting configurations. In this section, you create a function project that contains a single function.
31
-
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-typescript,programming-language-powershell,programming-language-python"
32
-
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
33
-
::: zone-end
34
31
::: zone pivot="programming-language-csharp"
32
+
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
35
33
36
34
```console
37
35
func init --worker-runtime dotnet-isolated
38
36
```
39
37
40
38
::: zone-end
41
39
::: zone pivot="programming-language-javascript"
42
-
40
+
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
49
+
50
50
```console
51
51
func init --worker-runtime powershell
52
52
```
53
53
54
54
::: zone-end
55
55
::: zone pivot="programming-language-python"
56
-
56
+
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
57
+
57
58
```console
58
59
func init --worker-runtime python
59
60
```
60
61
61
62
::: zone-end
62
63
::: zone pivot="programming-language-typescript"
64
+
1. In a terminal or command prompt, run this [`func init`](./functions-core-tools-reference.md#func-init) command to create a function app project in the current folder:
@@ -184,7 +186,7 @@ In Azure Functions, a function project is a container for one or more individual
184
186
185
187
To enable the Functions host to connect to the default storage account using shared secrets, you must replace the `AzureWebJobsStorage` connection string setting with a complex setting, prefixed with `AzureWebJobsStorage`, that uses the user-assigned managed identity to connect to the storage account.
186
188
187
-
1. Use this script to get the client ID of the user-assigned managed identity, and with it define a managed identity connections to storage and Application Insights:
189
+
1. Use this script to get the client ID of the user-assigned managed identity and uses it to define managed identity connections to both storage and Application Insights:
188
190
189
191
```azurecli
190
192
clientId=$(az identity show --name func-host-storage-user \
Copy file name to clipboardExpand all lines: includes/functions-create-azure-resources-flex-cli.md
+49-30Lines changed: 49 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Before you can deploy your function code to Azure, you need to create these reso
15
15
- A [user-assigned managed identity](/azure/active-directory/managed-identities-azure-resources/overview), which the Functions host uses to connect to the default storage account.
16
16
- A function app, which provides the environment for executing your function code. A function app maps to your local function project and lets you group functions as a logical unit for easier management, deployment, and sharing of resources.
17
17
18
-
Use the following commands to create these items. Both Azure CLI and PowerShell are supported.
18
+
Use the Azure CLI commands in these steps to create the required resources.
19
19
20
20
1. If you haven't done so already, sign in to Azure:
21
21
@@ -38,17 +38,21 @@ Use the following commands to create these items. Both Azure CLI and PowerShell
38
38
---
39
39
-->
40
40
41
-
1. If you haven't already done so, install the Application Insights extension:
41
+
1. If you haven't already done so, use this [`az extension add`](/cli/azure/extension#az-extension-add) command to install the Application Insights extension:
1. Create a resource group named `AzureFunctionsQuickstart-rg` in your chosen region:
47
+
1. Use this [az group create](/cli/azure/group#az-group-create) command to create a resource group named `AzureFunctionsQuickstart-rg` in your chosen region:
az group create --name "AzureFunctionsQuickstart-rg" --location "<REGION>"
53
+
```
50
54
51
-
The [az group create](/cli/azure/group#az-group-create) command creates a resource group. In the above command, replace `<REGION>` with a region near you that supports the Flex Consumption plan. Use an available region code returned from the [az functionapp list-flexconsumption-locations](/cli/azure/functionapp#az-functionapp-list-flexconsumption-locations) command.
55
+
In this example, replace `<REGION>` with a region near you that supports the Flex Consumption plan. Use the [az functionapp list-flexconsumption-locations](/cli/azure/functionapp#az-functionapp-list-flexconsumption-locations) command to view the list of currently supported regions.
52
56
<!---
53
57
### [Azure PowerShell](#tab/azure-powershell)
54
58
@@ -61,13 +65,16 @@ Use the following commands to create these items. Both Azure CLI and PowerShell
61
65
---
62
66
-->
63
67
64
-
1. Create a general-purpose storage account in your resource group and region:
68
+
1. Use this [az storage account create](/cli/azure/storage/account#az-storage-account-create) command to create a general-purpose storage account in your resource group and region:
This [az storage account create](/cli/azure/storage/account#az-storage-account-create) command creates a storage account.
77
+
71
78
<!---
72
79
### [Azure PowerShell](#tab/azure-powershell)
73
80
@@ -82,55 +89,62 @@ Use the following commands to create these items. Both Azure CLI and PowerShell
82
89
83
90
In this example, replace `<STORAGE_NAME>` with a name that is appropriate to you and unique in Azure Storage. Names must contain three to 24 characters numbers and lowercase letters only. `Standard_LRS` specifies a general-purpose account, which is [supported by Functions](../articles/azure-functions/storage-considerations.md#storage-account-requirements). This new account can only be accessed by using Microsoft Entra-authenticated identities that have been granted permissions to specific resources.
84
91
85
-
1. Create a user-assigned managed identity, then capture and parse the returned JSON properties of the object using `jq`:
92
+
1. Use this script to create a user-assigned managed identity, parse the returned JSON properties of the object using `jq`, and grant `Storage Blob Data Owner` permissions in the default storage account:
If you don't have the `jq` utility in your local Bash shell, it's available in Azure Cloud Shell. The [az identity create](/cli/azure/identity#az-identity-create) command creates a new identity in the resource group named `func-host-storage-user`. The returned `principalId` is used to assign permissions to this new identity in the default storage account by using the [`az role assignment create`](/cli/azure/role/assignment#az-role-assignment-create) command. The [`az storage account show`](/cli/azure/storage/account#az-storage-account-show) command is used to obtain the storage account ID.
If you don't have the `jq` utility in your local Bash shell, it's available in Azure Cloud Shell. In this example, replace `<STORAGE_NAME>` and `<REGION>` with your default storage account name and region, respectively.
94
108
95
-
In this example, replace `<STORAGE_NAME>` and `<REGION>` with your default storage account name and region, respectively.
109
+
The [az identity create](/cli/azure/identity#az-identity-create) command creates an identity named `func-host-storage-user`. The returned `principalId` is used to assign permissions to this new identity in the default storage account by using the [`az role assignment create`](/cli/azure/role/assignment#az-role-assignment-create) command. The [`az storage account show`](/cli/azure/storage/account#az-storage-account-show) command is used to obtain the storage account ID.
96
110
97
-
1. Use the [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command to create the function app in Azure:
111
+
1. Use this [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command to create the function app in Azure:
98
112
<!---Replace tabs when PowerShell cmdlets support Flex Consumption plans.
99
113
### [Azure CLI](#tab/azure-cli)
100
114
-->
101
115
::: zone pivot="programming-language-csharp"
102
116
```azurecli
103
117
az functionapp create --resource-group "AzureFunctionsQuickstart-rg" --name <APP_NAME> --flexconsumption-location <REGION> \
@@ -144,18 +158,23 @@ Use the following commands to create these items. Both Azure CLI and PowerShell
144
158
145
159
---
146
160
-->
147
-
In this example, replace these placeholders:
161
+
In this example, replace these placeholders with the appropriate values:
148
162
163
+
+ `<APP_NAME>`: a globally unique name appropriate to you. The `<APP_NAME>` is also the default DNS domain for the function app.
149
164
+ `<STORAGE_NAME>`: the name of the account you used in the previous step.
150
-
+ `<REGION>`: your region.
151
-
+ `<APP_NAME>`: a globally unique name appropriate to you. The `<APP_NAME>` is also the default DNS domain for the function app.
152
-
+ `<USER_NAME>`: the name of the user-assigned managed identity.
153
-
+ `<LANGUAGE_VERSION>`: use the [supported language stack version](../articles/azure-functions/supported-languages.md) you verified locally.
165
+
+ `<REGION>`: your current region.
166
+
+ `<LANGUAGE_VERSION>`: use the same [supported language stack version](../articles/azure-functions/supported-languages.md) you verified locally.
154
167
155
-
This command creates a function app running in your specified language runtime on Linux in the [Flex Consumption Plan](../articles/azure-functions/flex-consumption-plan.md), which is free for the amount of usage you incur here. The command also creates an associated Azure Application Insights instance in the same resource group, with which you can monitor your function app and view logs. For more information, see [Monitor Azure Functions](../articles/azure-functions/functions-monitoring.md). The instance incurs no costs until you activate it.
168
+
This command creates a function app running in your specified language runtime on Linux in the [Flex Consumption Plan](../articles/azure-functions/flex-consumption-plan.md), which is free for the amount of usage you incur here. The command also creates an associated Azure Application Insights instance in the same resource group, with which you can use to monitor your function app executions and view logs. For more information, see [Monitor Azure Functions](../articles/azure-functions/functions-monitoring.md). The instance incurs no costs until you activate it.
156
169
157
-
1. Add your user-assigned managed identity to the [Monitoring Metrics Publisher](../articles/role-based-access-control/built-in-roles/monitor.md#monitoring-metrics-publisher) role in your Application Insights instance:
170
+
1. Use this script to add your user-assigned managed identity to the [Monitoring Metrics Publisher](../articles/role-based-access-control/built-in-roles/monitor.md#monitoring-metrics-publisher) role in your Application Insights instance:
appInsights=$(az monitor app-insights component show --resource-group "AzureFunctionsQuickstart-rg" \
174
+
--app <APP_NAME> --query "id" --output tsv)
175
+
principalId=$(az identity show --name "func-host-storage-user" --resource-group "AzureFunctionsQuickstart-rg" \
176
+
--query principalId -o tsv)
177
+
az role assignment create --role "Monitoring Metrics Publisher" --assignee $principalId --scope $appInsights
178
+
```
160
179
161
-
The [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command adds your user to the role. The resource ID of your Application Insights instance is obtained by using [az monitor app-insights component show](/cli/azure/monitor/app-insights/component#az-monitor-app-insights-component-show).
180
+
In this example, replace `<APP_NAME>` with the name of your function app. The [az role assignment create](/cli/azure/role/assignment#az-role-assignment-create) command adds your user to the role. The resource ID of your Application Insights instance and the principal ID of your user are obtained by using the [az monitor app-insights component show](/cli/azure/monitor/app-insights/component#az-monitor-app-insights-component-show) and [`az identity show`](/cli/azure/identity#az-identity-show) commands, respectively.
0 commit comments