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/spring-apps/tutorial-managed-identities-functions.md
+34-29Lines changed: 34 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,18 +29,20 @@ Both Azure Functions and App Services have built in support for Azure Active Dir
29
29
30
30
## Create a resource group
31
31
32
-
A resource group is a logical container into which Azure resources are deployed and managed. Use the following command to create a resource group to contain a Function app. For more information, see [az group create](/cli/azure/group#az-group-create):
32
+
A resource group is a logical container into which Azure resources are deployed and managed. Use the following command to create a resource group to contain a Function app. For more information, see the [az group create](/cli/azure/group#az-group-create) command.
33
33
34
34
```azurecli
35
35
az group create --name <resource-group-name> --location <location>
36
36
```
37
37
38
-
## Create a Function App
38
+
## Create a Function app
39
39
40
-
To create a Function app you must first create a backing storage account, use the command [az storage account create](/cli/azure/storage/account#az-storage-account-create):
40
+
To create a Function app, you must first create a backing storage account. You can use the [az storage account create](/cli/azure/storage/account#az-storage-account-create) command.
41
41
42
42
> [!IMPORTANT]
43
-
> Each Function app and Storage Account must have a unique name. In the following command, replace *\<function-app-name>* with the name of your Function app and *\<storage-account-name>* with the name of your Storage Account.
43
+
> Each Function app and storage account must have a unique name.
44
+
45
+
Use the following command to create the storage account. Replace *\<function-app-name>* with the name of your Function app and *\<storage-account-name>* with the name of your storage account.
44
46
45
47
```azurecli
46
48
az storage account create \
@@ -50,7 +52,7 @@ az storage account create \
50
52
--sku Standard_LRS
51
53
```
52
54
53
-
After the Storage Account is created, use the following command to create the Function app.
55
+
After the storage account is created, use the following command to create the Function app.
54
56
55
57
```azurecli
56
58
az functionapp create \
@@ -63,37 +65,38 @@ az functionapp create \
63
65
--functions-version 3
64
66
```
65
67
66
-
Make a note of the returned `hostNames` value, which is in the format *https://\<your-functionapp-name>.azurewebsites.net*. You use this value in a following step.
68
+
Make a note of the returned `hostNames` value, which is in the format *https://\<your-functionapp-name>.azurewebsites.net*. Use this value in the Function app's root URL for testing the Function app.
67
69
68
70
## Enable Azure Active Directory Authentication
69
71
70
72
Use the following steps to enable Azure Active Directory authentication to access your Function app.
71
73
72
-
1. In the Azure portal, navigate to your resource group and open the Function app you created.
74
+
1. In the Azure portal, navigate to your resource group and then open the Function app you created.
73
75
1. In the navigation pane, select **Authentication** and then select **Add identity provider** on the main pane.
74
76
1. On the **Add an identity provider** page, select **Microsoft** from the **Identity provider** dropdown menu.
75
77
76
78
:::image type="content" source="media/spring-cloud-tutorial-managed-identities-functions/add-identity-provider.png" alt-text="Screenshot of the Azure portal showing the Add an identity provider page with Microsoft highlighted in the identity provider dropdown menu." lightbox="media/spring-cloud-tutorial-managed-identities-functions/add-identity-provider.png":::
77
79
78
-
1. On the **Basics** settings for the **Add an identity provider** page, set **Supported account type** to **Any Azure AD directory - Multi-tenant**.
79
-
1. Set **Unauthorized requests** to **HTTP 401 Unauthorized: recommended for APIs**. This setting ensures that all unauthenticated requests are denied (401 response).
80
+
1. Select **Add**.
81
+
1. For the **Basics** settings on the **Add an identity provider** page, set **Supported account types** to **Any Azure AD directory - Multi-tenant**.
82
+
1. Set **Unauthenticated requests** to **HTTP 401 Unauthorized: recommended for APIs**. This setting ensures that all unauthenticated requests are denied (401 response).
80
83
81
-
:::image type="content" source="media/spring-cloud-tutorial-managed-identities-functions/identity-provider-settings.png" alt-text="Screenshot of the Azure portal showing the settings page for adding an identity provider with the Any Azure AD directory Multi tenant option highlighted for the account type setting, and also showing the HTTP 401 Unauthorized recommended for APIs option highlighted for the Unauthenticated requests setting." lightbox="media/spring-cloud-tutorial-managed-identities-functions/identity-provider-settings.png":::
84
+
:::image type="content" source="media/spring-cloud-tutorial-managed-identities-functions/identity-provider-settings.png" alt-text="Screenshot of the Azure portal showing the settings page for adding an identity provider. This page highlights the 'supported account types' setting set to the 'Any Azure AD directory Multi tenant' option and also highlights the 'Unauthenticated requests' setting set to the 'HTTP 401 Unauthorized recommended for APIs' option." lightbox="media/spring-cloud-tutorial-managed-identities-functions/identity-provider-settings.png":::
82
85
83
86
1. Select **Add**.
84
87
85
-
After you add the settings, the Function app restarts and all subsequent requests are prompted to sign in through Azure AD. You can test that unauthenticated requests are currently being rejected by navigating to the Function app's root URL (returned in the `hostNames` output in a previous step). You should be redirected to your organization's Azure Active Directory sign-in screen.
88
+
After you add the settings, the Function app restarts and all subsequent requests are prompted to sign in through Azure AD. You can test that unauthenticated requests are currently being rejected with the Function app's root URL (returned in the `hostNames` output of the `az functionapp create` command). You should then be redirected to your organization's Azure Active Directory sign-in screen.
86
89
87
90
## Create an HTTP Triggered Function
88
91
89
-
In an empty local directory, create a new function app and add an HTTP triggered function.
92
+
In an empty local directory, use the following commands to create a new function and add an HTTP triggered function.
90
93
91
94
```console
92
95
func init --worker-runtime node
93
96
func new --template HttpTrigger --name HttpTrigger
94
97
```
95
98
96
-
By default, Functions use key-based authentication to secure HTTP endpoints. Since we're enabling Azure AD authentication to secure access to the Functions, we want to [set the function auth level to anonymous](../azure-functions/functions-bindings-http-webhook-trigger.md#secure-an-http-endpoint-in-production)in the *function.json* file.
99
+
By default, Functions use key-based authentication to secure HTTP endpoints. To enable Azure AD authentication to secure access to the Functions, set the `authLevel` key to `anonymous`in the *function.json* file.
97
100
98
101
```json
99
102
{
@@ -107,7 +110,9 @@ By default, Functions use key-based authentication to secure HTTP endpoints. Sin
107
110
}
108
111
```
109
112
110
-
You can now publish the app to the [Function app](#create-a-function-app) instance created in the previous step.
113
+
For more information, see the [Secure an HTTP endpoint in production](../azure-functions/functions-bindings-http-webhook-trigger.md#secure-an-http-endpoint-in-production) section of [Azure Functions HTTP trigger](../azure-functions/functions-bindings-http-webhook-trigger.md).
114
+
115
+
Use the following command to publish the app to the instance created in the previous step:
@@ -125,22 +130,22 @@ Functions in <your-functionapp-name>:
125
130
126
131
## Create Azure Spring Apps service and app
127
132
128
-
After installing the spring extension, create an Azure Spring Apps instance with the Azure CLI command `az spring create`.
133
+
Use the following commands to add the spring extension and to create a new instance of Azure Spring Apps.
129
134
130
135
```azurecli
131
136
az extension add --upgrade --name spring
132
137
az spring create \
133
-
--resource-group myResourceGroup \
134
-
--name mymsispringcloud \
135
-
--location eastus
138
+
--resource-group <resource-group-name> \
139
+
--name <Azure-Spring-Instance-name> \
140
+
--location <location>
136
141
```
137
142
138
-
The following example creates an app named `msiapp` with a system-assigned managed identity, as requested by the `--assign-identity` parameter.
143
+
Use the following command to create an app named `msiapp` with a system-assigned managed identity, as requested by the `--assign-identity` parameter.
139
144
140
145
```azurecli
141
146
az spring app create \
142
-
--resource-group "myResourceGroup" \
143
-
--service "mymsispringcloud" \
147
+
--resource-group <resource-group-name> \
148
+
--service <Azure-Spring-Apps-instance-name> \
144
149
--name "msiapp" \
145
150
--assign-endpoint true \
146
151
--assign-identity
@@ -150,13 +155,13 @@ az spring app create \
150
155
151
156
This sample invokes the HTTP triggered function by first requesting an access token from the [MSI endpoint](../active-directory/managed-identities-azure-resources/how-to-use-vm-token.md#get-a-token-using-http) and using that token to authenticate the Function http request.
152
157
153
-
1.Clone the sample project.
158
+
1.Use the following command clone the sample project.
0 commit comments