Skip to content

Commit 453d3fa

Browse files
committed
Final changes to 15-network-secured set-up
Final changes to 15-network-secured set-up
1 parent 603f1fe commit 453d3fa

File tree

9 files changed

+65
-23
lines changed

9 files changed

+65
-23
lines changed

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/CheckCapabilityHostReadiness.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if ($provisioningState -eq "Succeeded") {
1818
}
1919

2020
if ($provisioningState -eq "Failed" -or $provisioningState -eq "Canceled") {
21-
Write-Output "Provisioning State: $provisioningState, project provisionig will not work."
21+
Write-Output "Provisioning State: $provisioningState, project provisioning will not work."
2222
break;
2323
}
2424

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
subscriptionId="$1"
4+
resourcegroup="$2"
5+
accountName="$3"
6+
7+
if [[ -z "$subscriptionId" || -z "$resourcegroup" || -z "$accountName" ]]; then
8+
echo "Usage: $0 <subscriptionId> <resourcegroup> <accountName>"
9+
exit 1
10+
fi
11+
12+
while true; do
13+
token=$(az account get-access-token --subscription "$subscriptionId" --query accessToken -o tsv)
14+
uri="https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourcegroup/providers/Microsoft.CognitiveServices/accounts/$accountName/capabilityHosts/?api-version=2025-04-01-preview"
15+
content=$(az rest --method get --uri "$uri" --headers "Authorization=Bearer $token")
16+
provisioningState=$(echo "$content" | jq -r '.value[0].properties.provisioningState')
17+
18+
echo "Provisioning State: $provisioningState"
19+
20+
if [[ "$provisioningState" == "Succeeded" ]]; then
21+
echo "Provisioning State: $provisioningState, Please proceed with project creation template."
22+
break
23+
fi
24+
25+
if [[ "$provisioningState" == "Failed" || "$provisioningState" == "Canceled" ]]; then
26+
echo "Provisioning State: $provisioningState, project provisioning will not work."
27+
break
28+
fi
29+
30+
sleep 30
31+
done

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
* PNA disabled resources
55
* PE's to all resources
66
* Network injection enabled for Agents
7+
* Virtual Network Address speace support for Class B or Class C e.g. 172.16.0.0/16 or 192.168.0.0/16
8+
79

810
## Steps
911

1012
1. Create new (or use existing) resource group:
1113

1214
```bash
13-
az group create --name <new-rg-name> --location eastus
15+
az group create --name <new-rg-name> --location <your-rg-region>
1416
```
1517

1618
2. Deploy the main-create.bicep
@@ -24,10 +26,27 @@
2426
.\CheckCapabilityHostReadiness.ps1 -subscriptionId "<your-sub-id>" -resourcegroup "<new-rg-name>" -accountname "<your-aiservices-name>"
2527
```
2628

29+
If you do not want to run the Powershell script, you can run a bash script instead, from the file CheckCapabilityHostReadiness.sh. Run the following two commands:
30+
31+
```bash
32+
chmod +x CheckCapabilityHostReadiness.sh
33+
./CheckCapabilityHostReadiness.sh "<your-sub-id>" "<new-rg-name>" "<your-aiservices-name>"
34+
```
35+
2736
4. Deploy the main-project-caphost-create.bicep
2837

2938
```bash
30-
az deployment group create --resource-group <new-rg-name> --template-file main-project-caphost-create.bicep.bicep
39+
az deployment group create --resource-group <new-rg-name> --template-file main-project-caphost-create.bicep
40+
```
41+
42+
After running this script, you are required to input the following values:
43+
44+
```
45+
Please provide string value for 'accountName' (? for help): <your-account-name>
46+
Please provide string value for 'projectName' (? for help): <your-project-name>
47+
Please provide string value for 'aiSearchName' (? for help): <your-search-name>
48+
Please provide string value for 'azureStorageName' (? for help): <your-storage-name>
49+
Please provide string value for 'cosmosDBName' (? for help): <your-cosmosdb-name>
3150
```
3251

3352
**NOTE:** To access your Foundry resource securely, please using either a VM, VPN, or ExpressRoute.

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/main-create.bicep

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module aiAccount 'modules-network-secured/ai-account-identity.bicep' = {
102102
// modelVersion: modelVersion
103103
// modelSkuName: modelSkuName
104104
// modelCapacity: modelCapacity
105-
subnetId: vnet.outputs.subnetId
105+
agentSubnetId: vnet.outputs.agentSubnetId
106106
}
107107
}
108108
/*
@@ -198,7 +198,6 @@ module storageAccountRoleAssignment 'modules-network-secured/azure-storage-accou
198198
name: 'storage-${azureStorageName}-${uniqueSuffix}-deployment'
199199
scope: resourceGroup(azureStorageSubscriptionId, azureStorageResourceGroupName)
200200
params: {
201-
accountPrincipalId: aiAccount.outputs.accountPrincipalId
202201
azureStorageName: aiDependencies.outputs.azureStorageName
203202
projectPrincipalId: aiProject.outputs.projectPrincipalId
204203
}

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/ai-account-identity.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ param location string
55
// param modelVersion string
66
// param modelSkuName string
77
// param modelCapacity int
8-
param subnetId string
8+
param agentSubnetId string
99
param networkInjection string = 'true'
1010

1111
resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
@@ -30,7 +30,7 @@ resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
3030
networkInjections:((networkInjection == 'true') ? [
3131
{
3232
scenario: 'agent'
33-
subnetArmId: subnetId
33+
subnetArmId: agentSubnetId
3434
useMicrosoftManagedNetwork: false
3535
}
3636
] : null )

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/azure-storage-account-role-assignment.bicep

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
param accountPrincipalId string
21
param azureStorageName string
32
param projectPrincipalId string
43

@@ -14,15 +13,6 @@ resource storageBlobDataContributor 'Microsoft.Authorization/roleDefinitions@202
1413
scope: resourceGroup()
1514
}
1615

17-
// resource storageBlobDataContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
18-
// scope: storageAccount
19-
// name: guid(accountPrincipalId, storageBlobDataContributor.id, storageAccount.id)
20-
// properties: {
21-
// principalId: accountPrincipalId
22-
// roleDefinitionId: storageBlobDataContributor.id
23-
// principalType: 'ServicePrincipal'
24-
// }
25-
// }
2616
resource storageBlobDataContributorRoleAssignmentProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
2717
scope: storageAccount
2818
name: guid(projectPrincipalId, storageBlobDataContributor.id, storageAccount.id)

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/blob-storage-container-role-assignments.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ resource storageBlobDataOwner 'Microsoft.Authorization/roleDefinitions@2022-04-0
2020
scope: resourceGroup()
2121
}
2222

23-
2423
var conditionStr= '((!(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/read\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/filter/action\'}) AND !(ActionMatches{\'Microsoft.Storage/storageAccounts/blobServices/containers/blobs/tags/write\'}) ) OR (@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringStartsWithIgnoreCase \'${workspaceId}\' AND @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:name] StringLikeIgnoreCase \'*-azureml-agent\'))'
2524

2625
// Assign Storage Blob Data Owner role

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/standard-dependent-resources.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ resource aiSearch 'Microsoft.Search/searchServices@2024-06-01-preview' = if(!aiS
9090
publicNetworkAccess: 'disabled'
9191
replicaCount: 1
9292
semanticSearch: 'disabled'
93+
networkRuleSet: {
94+
bypass: 'None'
95+
ipRules: []
96+
}
9397
}
9498
sku: {
9599
name: 'standard'

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/modules-network-secured/vnet.bicep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Virtual Network Module
33
This module deploys the core network infrastructure with security controls:
44
55
1. Address Space:
6-
- VNet CIDR: 172.16.0.0/16
7-
- Hub Subnet: 172.16.0.0/24 (private endpoints)
8-
- Agents Subnet: 172.16.101.0/24 (container apps)
6+
- VNet CIDR: 172.16.0.0/16 OR 192.168.0.0/16
7+
- Agents Subnet: 172.16.0.0/24 OR 192.168.0.0/24
8+
- Private Endpoint Subnet: 172.16.101.0/24 OR 192.168.1.0/24
99
1010
2. Security Features:
11-
- Service endpoints
1211
- Network isolation
1312
- Subnet delegation
13+
- Private endpoint subnet
1414
*/
1515

1616
@description('Azure region for the deployment')
@@ -62,5 +62,5 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2024-05-01' = {
6262
// Output variables
6363
output peSubnetName string = peSubnetName
6464
output agentSubnetName string = agentSubnetName
65-
output subnetId string = '${virtualNetwork.id}/subnets/${agentSubnetName}'
65+
output agentSubnetId string = '${virtualNetwork.id}/subnets/${agentSubnetName}'
6666
output virtualNetworkName string = virtualNetwork.name

0 commit comments

Comments
 (0)