If you publish an Azure web app, it becomes public. If you need to protect your web app to only allow domain-based users to access the application, you can use standard functionality in Azure and Entra. You can even configure the application, so it can only be accessed by either specific users, or users in a specific group.
The steps
Here are the overarching steps:
- Create a new Application Registration to represent the web app.
- Configure settings in the Application registration and the Enterprise application.
- Update Authorization settings in the Web application.
Create a new application registration and Enterprise Application
- Create a new app and give it a good name.
A recommended pattern is
app-FullNameOfTheApplication-ENV-serviceTypeAbbriviation, such as:app-CoolAIStuff-DEV-web. - During creation, you can ignore the value for Redirect URI. for now.
Configure the Application Registration
Branding and properties
Update the Home page URL to point to your web app.
Under Authentication
- Click + Add a Platform and choose Web from the fly-out to the right.
- The Redirect URIs needs to be the full URL to the startpage of the app with this suffix:
/.auth/login/aad/callback. If the url is https://coolaistuff-dev-web.azurewebsites.net the Redirect URI will be https://coolaistuff-dev-web.azurewebsites.net/.auth/login/aad/callback - This following part is due to how you want to implement authentication within your app. This way you can protect your app without any code changes. Under Implicit grant and hybrid flows select ID Tokens (used for implicit and hybrid flows)
- Click Configure to proceed.
- Under Supported account types make sure to only select the single tenant option. unless you actually need to support other tenants. Lastly make sure that public client flows is not allowed.
Under Expose an API
The setting here is how your web application will communicate with Azure Entra. Make sure you configure everything correctly.
Application ID URI: Simply click the Add-link and then click save in the fly-out to the right. The URI should contain the client ID of the application registration.
Add a scope
- Scope name: user_impersonation
- Who can consent: Admins and users
- Admin consent display name: Access [name of your web app]
- Admin consent description: Allow access to [name of your web app]
- Repeat for the User settings.
- Click Add scope to save it.
Grant consent
To allow the application to use user impersonation, and make it possible for a user to login, you need to grant consent for the application. Under API Permissions, find and click on the “Grant admin consent for [domain name]“ option.
Under Owners
Assign one or more users to be responsible. This is only used for reference, if we want to know who owns an app.
Configure the Enterprise Application
This part is only needed if you want to add functionality to only allow specific users to access your web app. If not, everyone at the connected Entra domain has access. Finding the Enterprise application: Search for the application registration name on the Entra overview page.
Under Properties
Slide Assigment required to Yes. This will stop everyone in the connected Entra domain from gaining access. It will lock access to the users defined under the next step.
Under Users and Groups
Here you configure which users should have access to your web application.
- To add a user or a group, simply click + Add user/group at the top.
- Click on non selected under Users and groups.
- In the fly-out find the user or group you want to add.
- Click select and the Assign to add the user/group as being able to access the app.
When you assign a group to an application, only users directly in the group will have access. The assignment does not cascade to nested groups. As a bonus, in any Entra Group you can assing an owner and allow that owner to add or remove users in the group, effectively making them responsible for their own application. This is something that can be blocked by IT security policies though.
Update Authentication settings in the Web application
It is now time to add the protection you configured during application registration setup.
Authentication
- Click Add identity provider
- Select Microsoft as the identity provider
- App registration type, select the
Pick an existing…option. - In the dropdown, find your app registration you created earlier. You must use the name.
- Client secret expiration. Select Recommended 180 days.
- Client application requirement. Make sure Allow requests only from this application itself is selected.
- Identity requirement. Make sure Allow requests from any identity is selected.
- Tenant requirement. This depends on your needs. Usually you just have your own tenant.
- Pick save and start testing the application protection. The first sign is that you might need to login to the application.
If you update any access settings, such as adding a user to a group you have assigned to be able to access the application, it may take some time before the update is picked up and implemented by the app.


