Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions infra/abbreviations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"ai": {
"aiSearch": "srch-",
"aiServices": "aisa-",
"aiFoundry": "aif-",
"aiFoundryProject": "aifp-",
"aiVideoIndexer": "avi-",
"machineLearningWorkspace": "mlw-",
"openAIService": "oai-",
Expand Down
185 changes: 31 additions & 154 deletions infra/deploy_ai_foundry.bicep
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
// Creates Azure dependent resources for Azure AI studio
param solutionName string
param solutionLocation string
param keyVaultName string
param cuLocation string
param deploymentType string
param gptModelName string
param gptModelVersion string
param gptDeploymentCapacity int
// param embeddingModel string
// param embeddingDeploymentCapacity int
param managedIdentityObjectId string
param applicationInsightsId string
param containerRegistryId string

// Load the abbrevations file required to name the azure resources.
var abbrs = loadJsonContent('./abbreviations.json')

var storageName = '${abbrs.storage.storageAccount}${solutionName}hubs'
var storageSkuName = 'Standard_LRS'
var aiServicesName = '${abbrs.ai.aiServices}${solutionName}'
var aiFoundaryName = '${abbrs.ai.aiFoundry}${solutionName}'
var aiServicesName_cu = '${abbrs.ai.aiServices}${solutionName}-cu'
var location_cu = cuLocation
// var aiServicesName_m = '${solutionName}-aiservices_m'
// var location_m = solutionLocation
var location = solutionLocation //'eastus2'
var aiHubName = '${abbrs.ai.aiHub}${solutionName}'
var aiHubFriendlyName = aiHubName
var aiHubDescription = 'AI Hub for CPS template'
var aiProjectName = '${abbrs.ai.aiHubProject}${solutionName}'
var aiProjectFriendlyName = aiProjectName

var location = solutionLocation
var aiProjectDescription = 'AI foundary project for CPS template'
var aiProjectName = '${abbrs.ai.aiFoundryProject}${solutionName}'
var aiModelDeployments = [
{
name: gptModelName
Expand All @@ -51,14 +39,8 @@ var aiModelDeployments = [
// }
]

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVaultName
}

var storageNameCleaned = replace(storageName, '-', '')

resource aiServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
name: aiServicesName
resource aiFoundry 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = {
name: aiFoundaryName
location: location
identity: {
type: 'SystemAssigned'
Expand All @@ -68,15 +50,26 @@ resource aiServices 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
}
kind: 'AIServices'
properties: {
customSubDomainName: aiServicesName
apiProperties: {
// statisticsEnabled: false
}
allowProjectManagement: true
customSubDomainName: aiFoundaryName
publicNetworkAccess: 'Enabled'
disableLocalAuth: true
}
}

resource aiFoundryProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
parent: aiFoundry
name: aiProjectName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
description: aiProjectDescription
displayName: aiProjectName
}
}

resource aiServices_CU 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
name: aiServicesName_cu
location: location_cu
Expand All @@ -89,17 +82,14 @@ resource aiServices_CU 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
kind: 'AIServices'
properties: {
customSubDomainName: aiServicesName_cu
apiProperties: {
// statisticsEnabled: false
}
publicNetworkAccess: 'Enabled'
disableLocalAuth: true
}
}

@batchSize(1)
resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for aiModeldeployment in aiModelDeployments: {
parent: aiServices //aiServices_m
parent: aiFoundry //aiServices_m
name: aiModeldeployment.name
properties: {
model: {
Expand All @@ -115,129 +105,16 @@ resource aiServicesDeployments 'Microsoft.CognitiveServices/accounts/deployments
}
}]

resource storage 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: storageNameCleaned
location: location
sku: {
name: storageSkuName
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
allowBlobPublicAccess: false
allowCrossTenantReplication: false
allowSharedKeyAccess: true
encryption: {
keySource: 'Microsoft.Storage'
requireInfrastructureEncryption: false
services: {
blob: {
enabled: true
keyType: 'Account'
}
file: {
enabled: true
keyType: 'Account'
}
queue: {
enabled: true
keyType: 'Service'
}
table: {
enabled: true
keyType: 'Service'
}
}
}
isHnsEnabled: false
isNfsV3Enabled: false
keyPolicy: {
keyExpirationPeriodInDays: 7
}
largeFileSharesState: 'Disabled'
minimumTlsVersion: 'TLS1_2'
networkAcls: {
bypass: 'AzureServices'
defaultAction: 'Allow'
}
supportsHttpsTrafficOnly: true
}
}

@description('This is the built-in Storage Blob Data Contributor.')
resource blobDataContributor 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
scope: resourceGroup()
name: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
}

resource storageroleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
name: guid(resourceGroup().id, managedIdentityObjectId, blobDataContributor.id)
properties: {
principalId: managedIdentityObjectId
roleDefinitionId: blobDataContributor.id
principalType: 'ServicePrincipal'
}
}

resource aiHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview' = {
name: aiHubName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
// organization
friendlyName: aiHubFriendlyName
description: aiHubDescription

// dependent resources
keyVault: keyVault.id
storageAccount: storage.id
applicationInsights: applicationInsightsId
containerRegistry: containerRegistryId
}
kind: 'hub'
resource aiServicesConnection 'connections@2024-07-01-preview' = {
name: '${aiHubName}-connection-AzureOpenAI'
properties: {
category: 'AIServices'
target: aiServices.properties.endpoint
authType: 'AAD'
isSharedToAll: true
metadata: {
ApiType: 'Azure'
ResourceId: aiServices.id
}
}
dependsOn: [
aiServicesDeployments
]
}
}

resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' = {
name: aiProjectName
location: location
kind: 'Project'
identity: {
type: 'SystemAssigned'
}
properties: {
friendlyName: aiProjectFriendlyName
hubResourceId: aiHub.id
}
}

output aiServicesTarget string = aiServices.properties.endpoint //aiServices_m.properties.endpoint
output aiServicesTarget string = aiFoundry.properties.endpoint //aiServices_m.properties.endpoint
output aiServicesCUEndpoint string = aiServices_CU.properties.endpoint //aiServices_m.properties.endpoint
output aiServicesName string = aiServicesName //aiServicesName_m
output aiServicesId string = aiServices.id //aiServices_m.id
output aiFoundaryName string = aiFoundaryName //aiFoundaryName
output aiServicesId string = aiFoundry.id //aiServices_m.id
output aiServicesCuId string = aiServices_CU.id //aiServices_cu.id
output aiServicePrincipalId string = aiServices.identity.principalId
output aiServicePrincipalId string = aiFoundry.identity.principalId
output aiServiceCuPrincipalId string = aiServices_CU.identity.principalId

// output aiInfereceEndpoint string = phiserverless.properties.inferenceEndpoint.uri
output aiProjectPrincipalId string = aiHubProject.identity.principalId
output aiProjectConnectionString string = '${location}.api.azureml.ms;${subscription().subscriptionId};${resourceGroup().name};${aiHubProject.name}'
output aiProjectName string = aiHubProject.name
output aiProjectId string = aiHubProject.id
output aiProjectPrincipalId string = aiFoundry.identity.principalId
output aiProjectConnectionString string = aiFoundryProject.properties.endpoints['AI Foundry API']
output aiProjectName string = aiFoundryProject.name
output aiProjectId string = aiFoundryProject.id
4 changes: 0 additions & 4 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,11 @@ module aifoundry 'deploy_ai_foundry.bicep' = {
params: {
solutionName: solutionPrefix
solutionLocation: resourceGroupLocation
keyVaultName: kvault.outputs.keyvaultName
cuLocation: contentUnderstandingLocation
deploymentType: deploymentType
gptModelName: gptModelName
gptModelVersion: gptModelVersion
gptDeploymentCapacity: gptDeploymentCapacity
managedIdentityObjectId: managedIdentityModule.outputs.managedIdentityOutput.objectId
containerRegistryId: containerRegistry.outputs.createdAcrId
applicationInsightsId: applicationInsights.outputs.id
}
scope: resourceGroup(resourceGroup().name)
}
Expand Down
Loading
Loading