Configuring Azure Web App with authentication for different users, both inside and outside of Azure, can be achieved using Azure Active Directory (Azure AD) and its features. Here's a step-by-step guide to help you set up authentication for your Azure Web App without requiring admin approval for every new request:
Prerequisites:
- Azure subscription with an Azure AD tenant.
- Azure Web App created and deployed.
- Azure AD group created for the users who will access the web app.
Step 1: Register the Azure Web App in Azure AD
- Go to the Azure portal (https://portal.azure.com/) and sign in with your Azure AD credentials.
- Click on Azure Active Directory in the navigation menu.
- Click on App registrations and then click on New registration.
- Enter a name for your web app (e.g., "MyWebApp") and select Web as the platform.
- Enter the URL of your Azure Web App (e.g., https://mywebapp.azurewebsites.net/).
- Click on Register.
Step 2: Configure Azure AD Authentication for the Azure Web App
- In the Azure portal, navigate to your Azure Web App.
- Click on Authentication in the left-hand menu.
- Click on Add an authentication provider.
- Select Azure Active Directory as the authentication provider.
- Click on Configure.
- Select the Azure AD tenant and the app registration you created in Step 1.
- Choose the Authorization mode: Implicit or Authorization Code. For this example, choose Implicit.
- Click on Save.
Step 3: Configure Azure AD Group Membership
- In the Azure portal, navigate to your Azure AD group.
- Click on Members.
- Click on Add members.
- Search for the users you want to add to the group and select them.
- Click on Add.
Step 4: Configure Azure AD App Role
- In the Azure portal, navigate to your Azure AD app registration (created in Step 1).
- Click on App roles.
- Click on Create app role.
- Enter a name and description for the app role (e.g., "WebAppUser").
- Select User as the allowed member type.
- Click on Create.
Step 5: Assign Azure AD App Role to the Azure AD Group
- In the Azure portal, navigate to your Azure AD group.
- Click on Members.
- Click on Add members.
- Search for the Azure AD app registration (created in Step 1) and select it.
- Click on Add.
- Click on App roles.
- Select the app role you created in Step 4 (e.g., "WebAppUser").
- Click on Assign.
Step 6: Configure Azure Web App to use Azure AD App Role
- In the Azure portal, navigate to your Azure Web App.
- Click on Authentication in the left-hand menu.
- Click on Azure Active Directory.
- Click on Edit.
- In the App roles section, select the app role you created in Step 4 (e.g., "WebAppUser").
- Click on Save.
Step 7: Test Azure AD Authentication
- Go to your Azure Web App URL (e.g., https://mywebapp.azurewebsites.net/).
- You should be redirected to the Azure AD sign-in page.
- Sign in with a user account that is a member of the Azure AD group.
- If the user is a member of the group and has the assigned app role, they should be able to access the web app without requiring admin approval.
Configuring Azure AD to allow users to sign in without admin approval
To allow users to sign in without admin approval, you need to configure the User settings in Azure AD:
- In the Azure portal, navigate to Azure Active Directory.
- Click on User settings.
- Under Enterprise applications, select Users can consent to apps accessing company data on their behalf.
- Click on Save.
Additionally, you need to configure the App permissions for the Azure AD app registration:
- In the Azure portal, navigate to your Azure AD app registration.
- Click on API permissions.
- Under Microsoft Graph, select Delegated permissions.
- Select the User.Read permission.
- Click on Add permission.
- Click on Grant admin consent.
By following these steps, you have configured Azure Web App with authentication for different users, both inside and outside of Azure, using Azure AD and its features. Users who are members of the Azure AD group and have the assigned app role can sign in to the web app without requiring admin approval.