Azure OpenAI Private Endpoints: Connecting Across VNET’s
Published Aug 30 2023 11:58 AM 31.2K Views
Microsoft

Introduction to Azure OpenAI Private Endpoints:

 

Azure OpenAI Private Endpoints emerge as a pivotal solution within the Azure ecosystem. These endpoints play a vital role in fortifying the connection between your Azure resources and OpenAI services, ensuring that data transmission remains shielded from public internet exposure. By establishing a private link, Azure OpenAI Private Endpoints provide a secure and efficient channel for transmitting data between your infrastructure and the OpenAI service, mitigating potential security vulnerabilities associated with traditional public endpoints. This blog post takes you on a comprehensive journey, unraveling the intricate processes involved in setting up, configuring, and optimizing Azure OpenAI Private Endpoints, while shedding light on their indispensable role in safeguarding sensitive data in today's interconnected digital landscape.

 

Architecture:

 

freddydubon_0-1693365824695.jpeg

 

 

Environment Setup Guide:

Step 1. Create a VNet.

  • Go to https://portal.azure.com
  • Login if you already have an account, otherwise, create one
  • Create a new subscription
  • Create a new Azure VNet by using an ARM template or manually creating one.  Azure ARM (Azure Resource Manager) templates allow you to create and deploy an entire Azure infrastructure declaratively.
  • Create a subnet in each VNet where the VM with the Azure OpenAI script will reside.

Step 2. Azure Portal - Create a VM in each VNet\Subnet that will host OpenAI Script.

  • Create a new resource: click on the “create a resource” button on the left-hand side of the Azure portal.
  • Create a virtual machine (VM) in Azure:
    • Select Virtual Machine: In the "New" pane, search for "Virtual Machine" and select "Virtual Machine" from the list of available options.
    • Choose a deployment option: Azure offers two deployment models for virtual machines: Resource Manager and Classic. Choose the Resource Manager deployment model for the latest features and capabilities.
    • Configure the basics: Provide the necessary information such as the subscription, resource group, and virtual machine name. Select the region where you want to deploy the VM.
    • Select an image: Choose an operating system image for your VM, such as Windows or Linux. You can select from a range of pre-configured images available in the Azure Marketplace.
    • Choose a size: Select the size of the VM based on your requirements, considering factors such as CPU, memory, and storage capacity.
    • Configure optional features: Customize additional settings like networking, storage, availability options, and management options according to your needs. You can also configure advanced settings if required.
    • Set up authentication: Specify the username and password or SSH key for the VM's login credentials. This will be used to access the VM remotely.
    • Review and create: Double-check all the configurations you have made and click on the "Create" button to start the deployment process.
    • Monitor deployment: Azure will begin provisioning the VM based on your specifications. You can monitor the progress in the Azure Portal.
    • Access and manage the VM: Once the deployment is complete, you can access and manage the VM through the Azure Portal, Azure CLI, PowerShell, or any other preferred method.

Step 3. Update and configure VMs

  • Sudo update
  • Install Python PIP
    • Sudo apt-get install python3-pip
  • Install Azure OpenAI for Python script use
    • Sudo pip install openai

Setup VNet Peering between VNets:

Virtual Network (VNet) peering in Azure is a networking feature that allows seamless connectivity between two Azure Virtual Networks in the same region or across different regions. VNet peering enables resources within these VNets to communicate as if they were on the same network, without the need for any gateway devices or additional hardware. This secure and low-latency connection facilitates the sharing of resources, data, and services between VNets, enhancing application deployment flexibility and streamlining network architecture.

 

  • From the Azure portal select Virtual Networks
  • Select the Virtual Network you would like to Peer
  • Under Settings, Select Peerings

freddydubon_1-1693365824702.png

 

                                                      

  • Click on the add button

freddydubon_2-1693365824706.png

 

  • Name your peering connections both local and remote

freddydubon_3-1693365824710.png

 

 

  • Select the Remote Virtual Network (either same subscription or different subscription) as there is no difference in the configuration.

freddydubon_4-1693365824714.png

 

 

  • Click the Add button.
  • When the Peering status changes to “Connected” you are ready to proceed.

freddydubon_5-1693365824717.png

 

 

Configure OpenAI Private Endpoint:

  • From the Azure portal select Azure OpenAI
  • Select your Azure OpenAI instance

freddydubon_6-1693365824721.png

 

 

Make note of the Endpoint. This is the endpoint to be used even after the private endpoint is created, since DNS for the Destination VNet will be updated automatically as shown below.

The Azure Regions do not need to be the same. Azure OpenAI can be in one region and the destination VNet in a different Region.

 

  • Select Networking under Resource Management

                 

freddydubon_7-1693365824724.png

 

        

  • The First section is Firewalls and Virtual Networks.

If you intend to only allow access to this service using the Private endpoint and nothing else, set this to “Disabled.” Any other connection will NOT be allowed (Disabled).

                                                                       

freddydubon_8-1693365824727.png

 

                        

 

  • Click on + Private Endpoint

 

freddydubon_9-1693365824731.png

 

 

  • Select the Subscription
  • Resource Group
  • Enter a name for the private endpoint
  • The interface name will automatically use the name and will add “-nic”
  • This is the Network Interface that will be created in the destination VNet/Subnet (an IP address in that subnet will be assigned to this interface)
  • Select the Region for the End point.  This should be the same as where the destination VNet is located.

freddydubon_10-1693365824736.png

 

 

 

 

 

                                    Target Sub-resource is account

 

freddydubon_11-1693365824741.png

 

  • Select the Destination VNet and Subnet.  (A Network Interface will be created in this subnet and an interna IP address will be assigned)
  • If you do not see the correct VNet/Subnet, check the region.

 

freddydubon_12-1693365824744.png

 

 

  • By Default, the creation of a private endpoint will update the DNS settings of the Destination VNet.  This means that you can continue using the endpoint name (not the privatelink name) and the “regular” endpoint will correctly resolve to the internal IP address I.E 10.2.0.10.

freddydubon_13-1693365824749.png

 

  • Click Review and Create
  • Next verify and check the internal IP address given to the private endpoint.

freddydubon_14-1693365824752.png

 

 

  • You will see the Virtual Network/Subnet and interface, click on Network interface

freddydubon_15-1693365824756.png

 

 

  • You will see the private IP address given to the Private Endpoint. 

You can use this in your own DNS server or a local hosts file.

freddydubon_16-1693365824760.png

 

 

  • Nothing extra needs to be done when accessing the Azure OpenAI service from the same VNet where the endpoint was created.
  • However, for the Peered VNet, either the DNS needs to be updated to point to the internal IP address or the Hosts file needs to be updated.
  • Hosts File example for a Linux workstation

freddydubon_17-1693365824765.png

 

 

Other Networking Considerations:

When accessing this private endpoint from anywhere else, you need to follow this DNS example or use the internal IP address for your Endpoint connection. 

 

To further secure access to this endpoint, you can adjust the Network Security Group assigned to the Subnet where the endpoint was created.  Just make sure the security group is assigned to the subnet as shown below:

 

freddydubon_18-1693365824770.png

 

 

Adjusting the Inbound security rules or outbound security rules.

 

freddydubon_19-1693365824780.png

 

 

 

 

1 Comment
Co-Authors
Version history
Last update:
‎Aug 30 2023 11:58 AM
Updated by: