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
This article shows you how to create a managed identity for an Azure Spring Apps app and use it to invoke Http triggered Functions.
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
21
Both Azure Functions and App Services have built in support for Azure Active Directory (Azure AD) authentication. By leveraging 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.
22
22
@@ -39,43 +39,43 @@ az group create --name myResourceGroup --location eastus
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
-
> [!Important]
42
+
> [!IMPORTANT]
43
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.
Once the Storage Account has been created, you can create the Function app.
49
+
After the Storage Account is created, you can create the Function app.
50
50
51
51
```azurecli
52
52
az functionapp create --name <your-functionapp-name> --resource-group myResourceGroup --consumption-plan-location eastus --os-type windows --runtime node --storage-account <your-storageaccount-name> --functions-version 3
53
53
```
54
54
55
-
Make a note of the returned **hostNames**, which will be in the format *https://\<your-functionapp-name>.azurewebsites.net*. It will be used in a following step.
55
+
Make a note of the returned **hostNames**, which is in the format *https://\<your-functionapp-name>.azurewebsites.net*. You use this value in a following step.
56
56
57
57
## Enable Azure Active Directory Authentication
58
58
59
-
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 will ensure that all unauthenticated requests are denied (401 response).
59
+
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).
60
60
61
-

61
+
:::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":::
62
62
63
-
Under Authentication Providers, select Azure Active Directory to configure the application registration. Selecting Express Management Mode will automatically create an application registration in your Azure AD tenant with the correct configuration.
63
+
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.
64
64
65
-

65
+
:::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":::
66
66
67
-
Once you save the settings, the function app will restart and all subsequent requests will be 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 the step above). You should be redirected to your organizations Azure AD login screen.
67
+
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 the step above). You should be redirected to your organizations Azure AD login screen.
68
68
69
-
## Create an Http Triggered Function
69
+
## Create an HTTP Triggered Function
70
70
71
-
In an empty local directory, create a new function app and add an Http triggered function.
71
+
In an empty local directory, create a new function app and add an HTTP triggered function.
72
72
73
73
```console
74
74
func init --worker-runtime node
75
75
func new --template HttpTrigger --name HttpTrigger
76
76
```
77
77
78
-
By default Functions use key-based authentication to secure Http endpoints. Since we'll be 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.
78
+
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.
79
79
80
80
```json
81
81
{
@@ -89,7 +89,7 @@ By default Functions use key-based authentication to secure Http endpoints. Sinc
89
89
}
90
90
```
91
91
92
-
The app can now be published to the [Function app](#create-a-function-app) instance created in the previous step.
92
+
You can now publish the app to the [Function app](#create-a-function-app) instance created in the previous step.
@@ -122,53 +122,51 @@ az spring app create --name "msiapp" --service "mymsispringcloud" --resource-gro
122
122
123
123
## Build sample Spring Boot app to invoke the Function
124
124
125
-
This sample will invoke 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.
125
+
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.
0 commit comments