|
| 1 | +--- |
| 2 | +description: This set of templates demonstrates how to set up Azure AI Agent Service with virtual network isolation using User Managed Identity authetication for the AI Service/AOAI connection and private network links to connect the agent to your secure data. |
| 3 | +page_type: sample |
| 4 | +products: |
| 5 | +- azure |
| 6 | +- azure-resource-manager |
| 7 | +urlFragment: network-secured-agent |
| 8 | +languages: |
| 9 | +- bicep |
| 10 | +- json |
| 11 | +--- |
| 12 | + |
| 13 | +# Network-Secured Azure AI Agent Infrastructure with User Managed Identity |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fazureai-samples%2Fmain%2Fscenarios%2FAgents%2Fsetup%2Fnetwork-secured-agent-thread-storage%2Fazuredeploy.json) |
| 27 | + |
| 28 | +[](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fazureai-samples%2Fmain%2Fscenarios%2FAgents%2Fsetup%2Fnetwork-secured-agent-thread-storage%2Fazuredeploy.json) |
| 29 | + |
| 30 | +This infrastructure-as-code (IaC) solution deploys a network-secured Azure AI agent environment with private networking, managed identities, and role-based access control (RBAC). |
| 31 | + |
| 32 | + |
| 33 | +## Note: |
| 34 | +Make sure you have an active Azure subscription that allows registering resource providers. |
| 35 | +Subnet delegation requires the Microsoft.App provider to be registered in your subscription. If it's not already registered, run the command below: |
| 36 | + |
| 37 | +``` |
| 38 | +Register-AzResourceProvider -ProviderNamespace Microsoft.App |
| 39 | +``` |
| 40 | + |
| 41 | +In case Hub/Project workspace need Public Network Disabled select from dropdown or edit in bicep. |
| 42 | + |
| 43 | +``` |
| 44 | +hubPublicNetworkAccess = Disabled |
| 45 | +``` |
| 46 | + |
| 47 | +When Hub and Project workspace Public Network Disabled, the project connection string output from the deployment will look like, this should be used data plane operations |
| 48 | + |
| 49 | +``` |
| 50 | +PROJECT_CONNECTION_STRING='<project_workspace_id>.workspace.japaneast.api.azureml.ms;12345678-abcd-1234-9fc6-62780b3d3e05;my-resource-group;my-project-name' |
| 51 | +``` |
| 52 | + |
| 53 | +It follows format |
| 54 | +```<HostName>;<AzureSubscriptionId>;<ResourceGroup>;<ProjectName>``` |
| 55 | +HostName can be found by navigating to your discovery_url and removing the leading "https://" and trailing "/discovery" |
| 56 | +To find your discovery_url, run the CLI command: |
| 57 | +```az ml workspace show -n {project_name} --resource-group {resource_group_name} --query discovery_url``` |
| 58 | +Customer needs to login to Azure subscription via Azure CLI and set the environment variables |
| 59 | + |
| 60 | + |
| 61 | +## Architecture Overview |
| 62 | + |
| 63 | +### Network Security Design |
| 64 | + |
| 65 | +The deployment creates an isolated network environment: |
| 66 | + |
| 67 | +- **Virtual Network (172.16.0.0/16)** |
| 68 | + - Customer Hub Subnet (172.16.0.0/24): Hosts private endpoints |
| 69 | + - Agents Subnet (172.16.101.0/24): For azure ai agent workloads |
| 70 | + |
| 71 | +- **Private Endpoints** |
| 72 | + - AI Services |
| 73 | + - AI Search |
| 74 | + - Key Vault |
| 75 | + - Storage Account |
| 76 | + - Cosmos DB |
| 77 | + |
| 78 | +- **Private DNS Zones** |
| 79 | + - privatelink.azureml.ms |
| 80 | + - privatelink.search.windows.net |
| 81 | + - privatelink.blob.core.windows.net |
| 82 | + - privatelink.documents.azure.com |
| 83 | + |
| 84 | +### Core Components |
| 85 | + |
| 86 | +1. **AI Hub** |
| 87 | + - Central orchestration point |
| 88 | + - Manages service connections |
| 89 | + - Network-isolated capability hosts |
| 90 | + |
| 91 | +2. **AI Project** |
| 92 | + - Workspace configuration |
| 93 | + - Service integration |
| 94 | + - Agent deployment |
| 95 | + |
| 96 | +3. **Supporting Services** |
| 97 | + - Azure AI Services |
| 98 | + - Azure AI Search |
| 99 | + - Key Vault |
| 100 | + - Storage Account |
| 101 | + - Cosmos DB Account |
| 102 | + |
| 103 | +## Security Features |
| 104 | + |
| 105 | +### Authentication & Authorization |
| 106 | + |
| 107 | +- **Managed Identity** |
| 108 | + - Zero-trust security model |
| 109 | + - No credential storage |
| 110 | + - Platform-managed rotation |
| 111 | + |
| 112 | +- **Role Assignments** |
| 113 | + - AI Services: Administrator, OpenAI User |
| 114 | + - AI Search: Index Data Contributor, Service Contributor |
| 115 | + - Key Vault: Contributor, Secrets Officer |
| 116 | + - Storage: Blob Data Owner, Queue Data Contributor |
| 117 | + - Cosmos DB: DocumentDB Account Operator Role, Cosmos DB Built-In Data Contributor |
| 118 | + |
| 119 | +### Network Security |
| 120 | + |
| 121 | +- Public network access disabled |
| 122 | +- Private endpoints for all services |
| 123 | +- Service endpoints for Azure services |
| 124 | +- Network ACLs with deny by default |
| 125 | + |
| 126 | +## Deployment Options |
| 127 | + |
| 128 | +### 1. Infrastructure as Code (Bicep) |
| 129 | +```bash |
| 130 | +az deployment group create \ |
| 131 | + --template-file main.bicep \ |
| 132 | + --parameters @parameters.json |
| 133 | +``` |
| 134 | +Features: |
| 135 | +- Declarative approach |
| 136 | +- Native Azure integration |
| 137 | +- Easy to version control |
| 138 | +- Clear resource dependencies |
| 139 | + |
| 140 | +## Module Structure |
| 141 | + |
| 142 | +``` |
| 143 | +modules-network-secured/ |
| 144 | +├── ai-search-role-assignments.bicep # AI Search RBAC configuration |
| 145 | +├── ai-search-service.bicep # AI Search deployment |
| 146 | +├── ai-service-role-assignments.bicep # AI Services RBAC configuration |
| 147 | +├── cognitive-services-role-assignments.bicep # OpenAI permissions |
| 148 | +├── keyvault-role-assignments.bicep # Key Vault RBAC configuration |
| 149 | +├── network-secured-ai-hub.bicep # AI Hub deployment |
| 150 | +├── network-secured-ai-project.bicep # AI Project deployment |
| 151 | +├── network-secured-dependent-resources.bicep # Core infrastructure |
| 152 | +├── network-secured-identity.bicep # Managed identity |
| 153 | +├── private-endpoint-and-dns.bicep # Network security |
| 154 | +├── cosmos-account-role-assignments.bicep # Cosmos Account RBAC |
| 155 | +├── cosmos-container-role-assignments.bice # Cosmos Container RBAC |
| 156 | +└── storage-role-assignments.bicep # Storage RBAC configuration |
| 157 | +
|
| 158 | +``` |
| 159 | + |
| 160 | +## Role Assignments |
| 161 | + |
| 162 | +The deployment configures the following RBAC permissions: |
| 163 | + |
| 164 | +### AI Services |
| 165 | +- Azure AI Administrator (b78c5d69-af96-48a3-bf8d-a8b4d589de94) |
| 166 | + * Full access to manage AI resources |
| 167 | + * Model deployment permissions |
| 168 | + * Security settings management |
| 169 | + |
| 170 | +### AI Search |
| 171 | +- Search Index Data Contributor (8ebe5a00-799e-43f5-93ac-243d3dce84a7) |
| 172 | + * Read/write access to indexes |
| 173 | + * Query and update operations |
| 174 | +- Search Service Contributor (7ca78c08-252a-4471-8644-bb5ff32d4ba0) |
| 175 | + * Service management access |
| 176 | + * Configuration changes |
| 177 | + |
| 178 | +### Key Vault |
| 179 | +- Key Vault Contributor (f25e0fa2-a7c8-4377-a976-54943a77a395) |
| 180 | + * Manage vault properties |
| 181 | + * Cannot access secrets |
| 182 | +- Key Vault Secrets Officer (b86a8fe4-44ce-4948-aee5-eccb2c155cd7) |
| 183 | + * Full secrets access |
| 184 | + * Manage secret metadata |
| 185 | + |
| 186 | +### Storage |
| 187 | +- Storage Blob Data Owner (b7e6dc6d-f1e8-4753-8033-0f276bb0955b) |
| 188 | + * Full blob access |
| 189 | + * Container management |
| 190 | +- Storage Queue Data Contributor (974c5e8b-45b9-4653-ba55-5f855dd0fb88) |
| 191 | + * Queue operations |
| 192 | + * Message management |
| 193 | + |
| 194 | +### Cosmos DB Account |
| 195 | +- DocumentDB Account Operator Role(230815da-be43-4aae-9cb4-875f7bd000aa) |
| 196 | +- Cosmos DB Built-In Data Contributor Role (00000000-0000-0000-0000-000000000002) |
| 197 | + |
| 198 | +## Networking Details |
| 199 | + |
| 200 | +### Private Endpoints |
| 201 | +Each service is deployed with a private endpoint in the Customer Hub subnet: |
| 202 | + |
| 203 | +```plaintext |
| 204 | +AI Services: account |
| 205 | +AI Search: searchService |
| 206 | +Storage: blob |
| 207 | +Cosmos DB: sql |
| 208 | +``` |
| 209 | + |
| 210 | +### DNS Configuration |
| 211 | +Private DNS zones are created and linked to the VNet: |
| 212 | + |
| 213 | +```plaintext |
| 214 | +AI Services: privatelink.azureml.ms |
| 215 | +AI Search: privatelink.search.windows.net |
| 216 | +Storage: privatelink.blob.core.windows.net |
| 217 | +Cosmos DB: privatelink.documents.azure.com |
| 218 | +``` |
| 219 | + |
| 220 | +## Security Considerations |
| 221 | + |
| 222 | +1. **Network Isolation** |
| 223 | + - No public internet exposure |
| 224 | + - Private endpoint access only |
| 225 | + - Network ACLs with deny-by-default |
| 226 | + |
| 227 | +2. **Authentication** |
| 228 | + - Managed identity authentication |
| 229 | + - No stored credentials |
| 230 | + - AAD integration |
| 231 | + |
| 232 | +3. **Authorization** |
| 233 | + - Granular RBAC assignments |
| 234 | + - Principle of least privilege |
| 235 | + - Service-specific roles |
| 236 | + |
| 237 | +4. **Monitoring** |
| 238 | + - Diagnostic settings enabled |
| 239 | + - Activity logging |
| 240 | + - Network monitoring |
| 241 | + |
| 242 | +## Limitations |
| 243 | +- AI Services/Azure OpenAI resource must be in the same region as Hub and Project workspace. This restriction would be removed in next revision (coming soon). |
| 244 | +- The capability host sub-resources of Hub/Project must be deleted before deleting the Hub/Project resource itself. You can use the script as sample to delete it or can be done in alternate ways via ARM. This restriction would be removed in next revision (coming soon). |
| 245 | + - [Run delete script](../utils/deleteCaphost.sh) |
| 246 | + |
| 247 | + |
| 248 | +## Maintenance |
| 249 | + |
| 250 | +### Regular Tasks |
| 251 | +1. Review role assignments |
| 252 | +2. Monitor network security |
| 253 | +3. Check service health |
| 254 | +4. Update configurations as needed |
| 255 | + |
| 256 | +### Troubleshooting |
| 257 | +1. Verify private endpoint connectivity |
| 258 | +2. Check DNS resolution |
| 259 | +3. Validate role assignments |
| 260 | +4. Review network security groups |
| 261 | + |
| 262 | +## References |
| 263 | + |
| 264 | +- [Azure AI Services Documentation](https://learn.microsoft.com/en-us/azure/ai-services/) |
| 265 | +- [Private Endpoint Documentation](https://learn.microsoft.com/en-us/azure/private-link/) |
| 266 | +- [RBAC Documentation](https://learn.microsoft.com/en-us/azure/role-based-access-control/) |
| 267 | +- [Network Security Best Practices](https://learn.microsoft.com/en-us/azure/security/fundamentals/network-best-practices) |
| 268 | + |
| 269 | +`Tags: ` |
0 commit comments