Configure network isolation
Commencing September 1, 2023, it is strongly advised to employ the Azure Service Tag method for network isolation. The utilization of DL-ASE should be limited to highly specific scenarios. Prior to implementing this solution in a production environment, we kindly recommend consulting your support team for guidance.
You can add network isolation to an existing Direct Line App Service extension bot. A private endpoint lets your network isolated bot communicate with required Bot Framework services so that the bot can run correctly while being limited to the virtual network.
To add network isolation to your bot:
- Use a virtual network and configure the network to prevent outbound traffic. At this point, your bot will lose the ability to communicate with other Bot Framework services.
- Configure private endpoints to restore connectivity.
- Restart you app service and test your bot within your isolated network.
- Disable public network access to your bot.
Prerequisites
- An Azure account. If you don't already have one, create a free account before you begin.
- A subscription with permission to create Azure Virtual Network and network security group resources.
- A working Direct Line App Service extension bot.
- Your bot uses the Bot Framework SDK for C# or JavaScript, version 4.16 or later.
- Your bot has named pipes enabled.
- Your bot's app service has the Direct Line App Service extension enabled.
- A Web Chat control connected to your bot's Direct Line client.
To confirm that your existing bot is configured correctly:
In a browser, open the Direct Line client endpoint for your bot. For example,
https://<your-app_service>.azurewebsites.net/.bot
.Verify the page displays the following:
{"v":"123","k":true,"ib":true,"ob":true,"initialized":true}
- v shows the build version of the Direct Line App Service extension.
- k indicates whether the extension was able to read an extension key from its configuration.
- initialized indicates whether the extension was able to download bot metadata from Azure AI Bot Service.
- ib indicates whether the extension was able to establish an inbound connection to the bot.
- ob indicates whether the extension was able to establish an outbound connection from the bot.
Create a virtual network
- Go to Azure portal.
- Create an Azure Virtual Network resource in the same region as your bot.
- This creates both a virtual network and a subnet.
- Don't create any virtual machines.
- For general instructions, see Create a virtual network using the Azure portal.
- Open the app service resource for your bot and enable virtual network integration.
- Use the virtual network and subnet from the previous step.
- For general instructions, see Enable virtual network integration in Azure App Service.
- Create a second subnet. You'll use the second subnet later to add your private endpoint.
Deny outbound traffic from your network
- Open the network security group associated with your first subnet.
- If no security group is configured, create one. For more information, see Network security groups.
- Under Settings, select Outbound security rules.
- In the outbound security rules list, enable DenyAllInternetOutbound.
- Go to the app service resource for your bot.
- Restart your app service.
Verify that connectivity is broken
In a separate browser tab, open the Direct Line client endpoint for your bot. For example,
https://<your-app_service>.azurewebsites.net/.bot
.Verify the page displays the following:
{"v":"123","k":true,"ib":true,"ob":true,"initialized":false}
The value of
initialized
should befalse
, because your app service and app service extension are unable to connect to other Bot Framework services to initialize itself. Your bot is now isolated in a virtual network for outbound connections.
Create your private endpoint
- Go to Azure portal.
- Open the Azure Bot resource for your bot.
- Under Settings, select Networking.
- On the Private access tab and select Create a private endpoint.
- On the Resource tab, for Target sub-resource, select Bot from the list.
- On the Virtual Network tab, select your virtual network and the second subnet you created.
- Save your private endpoint.
- On the Private access tab and select Create a private endpoint.
Add your private endpoint to your bot's app service
- Open the Azure App Service resource for your bot.
- Under Settings, select Configuration.
- On the Application settings tab, select New application setting.
- Set Name to
DirectLineExtensionABSEndpoint
. - Set Value to the private endpoint URL, for example,
https://<your_azure_bot>.privatelink.directline.botframework.com/v3/extension
. - Save the new setting.
- Set Name to
- On the Application settings tab, select New application setting.
Restart your app service and verify that connectivity is restored
Restart the app service for your bot.
In a separate browser tab, open the Direct Line client endpoint for your bot. For example,
https://<your-app_service>.azurewebsites.net/.bot
.Verify the page displays the following:
{"v":"123","k":true,"ib":true,"ob":true,"initialized":true}
The value of
initialized
should betrue
.Use the Web Chat control connected to your bot's Direct Line client to interact with your bot inside the private network.
If your private endpoint doesn't work correctly, you can add a rule to allow outbound traffic specifically to Azure AI Bot Service.
Note
This will make you virtual network a little less isolated.
- Open the network security group associated with your first subnet.
- Under Settings, select Outbound security rules.
- In the outbound security rules list, enable AllowAzureBotService.
- Go to the app service resource for your bot.
- Restart your app service.
Disable public network access to your bot
You can block public access to your Azure AI Bot Service and only allow access through Private Endpoint. You can disable network access of Azure AI Bot Service in Azure portal.
Tip
This will unconfigure the Teams channels. No other channels (except Direct Line) can be configurated or updated in Azure portal.
- Go to Azure portal.
- Open the app service for your bot.
- Disable public network access.
Additional information
Virtual network configuration
You have a couple options to configure your bot for a virtual network.
- Create a virtual network and then enable Azure App Service within the network. This is the option used in this article.
- Create an App Service environment and then add an App Service Plan within the environment.
- Create a virtual network.
- Enable Azure App Service integration within the virtual network.
These are the steps used in this article, as described in the Create a virtual network section.
For more information, see Create a virtual network using the Azure portal and Enable virtual network integration in Azure App Service.