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
+24-17Lines changed: 24 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ ms.date: 07/10/2020
18
18
19
19
This article shows you how to create a managed identity for an Azure Spring Apps app and use it to invoke HTTP triggered Functions.
20
20
21
-
Both Azure Functions and App Services have built in support for Azure Active Directory (Azure AD) authentication. By using this built-in authentication capability along with Managed Identities for Azure Spring Apps, we can invoke RESTful services using modern OAuth semantics. This method doesn't require storing secrets in code and provides more granular controls for controlling access to external resources.
21
+
Both Azure Functions and App Services have built in support for Azure Active Directory (Azure AD) authentication. By using this built-in authentication capability along with Managed Identities for Azure Spring Apps, you can invoke RESTful services using modern OAuth semantics. This method doesn't require storing secrets in code and provides more granular controls for controlling access to external resources.
22
22
23
23
## Prerequisites
24
24
@@ -29,53 +29,60 @@ 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. Create a resource group to contain both the Function app and Spring Cloud using the command[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[az group create](/cli/azure/group#az-group-create):
33
33
34
34
```azurecli
35
-
az group create --name myResourceGroup --location eastus
35
+
az group create --name <resource-group-name> --location <location>
36
36
```
37
37
38
38
## Create a Function App
39
39
40
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):
41
41
42
42
> [!IMPORTANT]
43
-
> Each Function app and Storage Account must have a unique name. Replace *\<your-functionapp-name>* with the name of your Function app and *\<your-storageaccount-name>* with the name of your Storage Account in the following examples.
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.
44
44
45
45
```azurecli
46
46
az storage account create \
47
-
--resource-group myResourceGroup \
48
-
--name <your-storageaccount-name> \
49
-
--location eastus \
47
+
--resource-group <resource-group-name> \
48
+
--name <storage-account-name> \
49
+
--location <location> \
50
50
--sku Standard_LRS
51
51
```
52
52
53
-
After the Storage Account is created, you can create the Function app.
53
+
After the Storage Account is created, use the following command to create the Function app.
54
54
55
55
```azurecli
56
56
az functionapp create \
57
-
--resource-group myResourceGroup \
58
-
--name <your-functionapp-name> \
59
-
--consumption-plan-location eastus \
57
+
--resource-group <resource-group-name> \
58
+
--name <function-app-name> \
59
+
--consumption-plan-location <location> \
60
60
--os-type windows \
61
61
--runtime node \
62
-
--storage-account <your-storageaccount-name> \
62
+
--storage-account <storage-account-name> \
63
63
--functions-version 3
64
64
```
65
65
66
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.
67
67
68
68
## Enable Azure Active Directory Authentication
69
69
70
-
Access the newly created Function app from the [Azure portal](https://portal.azure.com) and select **Authentication / Authorization** from the settings menu. Enable App Service Authentication and set the **Action to take when request is not authenticated** to **Log in with Azure Active Directory**. This setting ensures that all unauthenticated requests are denied (401 response).
70
+
Use the following steps to enable Azure Active Directory authentication to access your Function app.
71
+
72
+
1. In the Azure portal, navigate to your resource group and open the Function app you created.
73
+
1. In the navigation pane, select **Authentication** and then select **Add identity provider** on the main pane.
74
+
1. On the **Add an identity provider** page, select **Microsoft** from the **Identity provider** dropdown menu.
75
+
76
+
:::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":::
71
77
72
-
:::image type="content" source="media/spring-cloud-tutorial-managed-identities-functions/function-auth-config-1.jpg" alt-text="Screenshot of the Azure portal showing Authentication / Authorization page with Azure Active Directory set as the default provider." lightbox="media/spring-cloud-tutorial-managed-identities-functions/function-auth-config-1.jpg":::
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).
73
80
74
-
Under **Authentication Providers**, select **Azure Active Directory** to configure the application registration. Selecting **Express Management Mode** automatically creates an application registration in your Azure AD tenant with the correct configuration.
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":::
75
82
76
-
:::image type="content" source="media/spring-cloud-tutorial-managed-identities-functions/function-auth-config-2.jpg" alt-text="Screenshot of the Azure portal showing the Azure Active Directory provider set to Express Management Mode." lightbox="media/spring-cloud-tutorial-managed-identities-functions/function-auth-config-2.jpg":::
83
+
1. Select **Add**.
77
84
78
-
After you save the settings, the function app restarts and all subsequent requests are prompted to log in via Azure AD. You can test that unauthenticated requests are now being rejected by navigating to the function apps root URL (returned in the `hostNames` output in a previous step). You should be redirected to your organizations Azure AD login screen.
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.
0 commit comments