|
| 1 | +/* |
| 2 | + AI Foundry account and project - with public network access disabled |
| 3 | + |
| 4 | + Description: |
| 5 | + - Creates an AI Foundry (previously known as Azure AI Services) account and public network access disabled. |
| 6 | + - Creates a gpt-4o model deployment |
| 7 | +*/ |
| 8 | +@description('That name is the name of our application. It has to be unique. Type a name followed by your resource group name. (<name>-<resourceGroupName>)') |
| 9 | +param aiFoundryName string = 'entraid-foundry' |
| 10 | + |
| 11 | +@description('Location for all resources.') |
| 12 | +param location string = 'eastus' |
| 13 | + |
| 14 | +@description('Name of the first project') |
| 15 | +param projectName string = '${aiFoundryName}-proj' |
| 16 | +@description('This project will be a sub-resource of your account') |
| 17 | +param projectDescription string = 'A project for the AI Foundry account with storage account' |
| 18 | +@description('The display name of the project') |
| 19 | +param displayName string = 'project' |
| 20 | + |
| 21 | +@description('Name of the storage account') |
| 22 | +param azureStorageName string = 'entraidfoundry' |
| 23 | + |
| 24 | +@description('Storage account sku') |
| 25 | +param noZRSRegions array = ['southindia', 'westus'] |
| 26 | +param sku object = contains(noZRSRegions, location) ? { name: 'Standard_GRS' } : { name: 'Standard_ZRS' } |
| 27 | + |
| 28 | +/* |
| 29 | + Step 1: Create dependent resource - Storage account |
| 30 | +*/ |
| 31 | +resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = { |
| 32 | + name: azureStorageName |
| 33 | + location: location |
| 34 | + kind: 'StorageV2' |
| 35 | + sku: sku |
| 36 | + properties: { |
| 37 | + minimumTlsVersion: 'TLS1_2' |
| 38 | + allowBlobPublicAccess: false |
| 39 | + publicNetworkAccess: 'Disabled' |
| 40 | + networkAcls: { |
| 41 | + bypass: 'AzureServices' |
| 42 | + defaultAction: 'Deny' |
| 43 | + virtualNetworkRules: [] |
| 44 | + } |
| 45 | + allowSharedKeyAccess: false |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +/* |
| 50 | + Step 2: Create an Account |
| 51 | +*/ |
| 52 | +resource account 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = { |
| 53 | + name: aiFoundryName |
| 54 | + location: location |
| 55 | + identity: { |
| 56 | + type: 'SystemAssigned' |
| 57 | + } |
| 58 | + kind: 'AIServices' |
| 59 | + sku: { |
| 60 | + name: 'S0' |
| 61 | + } |
| 62 | + properties: { |
| 63 | + // Networking |
| 64 | + publicNetworkAccess: 'Disabled' |
| 65 | + // Specifies whether this resource support project management as child resources, used as containers for access management, data isolation, and cost in AI Foundry. |
| 66 | + allowProjectManagement: true |
| 67 | + // Defines developer API endpoint subdomain |
| 68 | + customSubDomainName: aiFoundryName |
| 69 | + // Auth |
| 70 | + disableLocalAuth: false |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +/* |
| 75 | + Step 3: Create project |
| 76 | +*/ |
| 77 | +resource project 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = { |
| 78 | + parent: account |
| 79 | + name: projectName |
| 80 | + location: location |
| 81 | + identity: { |
| 82 | + type: 'SystemAssigned' |
| 83 | + } |
| 84 | + properties: { |
| 85 | + description: projectDescription |
| 86 | + displayName: displayName |
| 87 | + } |
| 88 | + |
| 89 | + resource project_connection_azure_storage 'connections@2025-04-01-preview' = { |
| 90 | + name: azureStorageName |
| 91 | + properties: { |
| 92 | + category: 'AzureStorageAccount' |
| 93 | + target: storage.properties.primaryEndpoints.blob |
| 94 | + authType: 'AAD' |
| 95 | + metadata: { |
| 96 | + ApiType: 'Azure' |
| 97 | + ResourceId: storage.id |
| 98 | + location: storage.location |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +/* |
| 105 | + Step 4: Assign storage account roles |
| 106 | +*/ |
| 107 | + |
| 108 | +// Storage Blob Data Owner Role |
| 109 | +resource storageBlobDataOwner 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { |
| 110 | + name: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' // Built-in role ID |
| 111 | + scope: resourceGroup() |
| 112 | +} |
| 113 | + |
| 114 | +// Assign Storage Blob Data Owner role |
| 115 | +resource storageBlobDataOwnerAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { |
| 116 | + scope: storage |
| 117 | + name: guid(storageBlobDataOwner.id, storage.id) |
| 118 | + properties: { |
| 119 | + principalId: project.identity.principalId |
| 120 | + roleDefinitionId: storageBlobDataOwner.id |
| 121 | + principalType: 'ServicePrincipal' |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | + |
| 126 | + |
0 commit comments