Skip to content
Open
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
68 changes: 68 additions & 0 deletions scenarios/Agents/modules-basic-keys/basic-ai-hub-keys.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Creates an Azure AI resource with proxied endpoints for the Azure AI services provider

@description('Azure region of the deployment')
param location string

@description('Tags to add to the resources')
param tags object

@description('AI hub name')
param aiHubName string

@description('AI hub display name')
param aiHubFriendlyName string = aiHubName

@description('AI hub description')
param aiHubDescription string

@description('Resource ID of the storage account resource for storing experimentation outputs')
param storageAccountId string

@description('Resource ID of the AI Services resource')
param aiServicesId string

@description('Resource ID of the AI Services endpoint')
param aiServicesTarget string

@description('Model/AI Resource deployment location')
param modelLocation string

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

// dependent resources
storageAccount: storageAccountId
}
kind: 'hub'

resource aiServicesConnection 'connections@2024-07-01-preview' = {
name: '${aiHubName}-connection-AIServices'
properties: {
category: 'AIServices'
target: aiServicesTarget
// useWorkspaceManagedIdentity: true
authType: 'ApiKey'
isSharedToAll: true
credentials: {
key: '${listKeys(aiServicesId, '2022-10-01').key1}'
}
metadata: {
ApiType: 'Azure'
ResourceId: aiServicesId
Location: modelLocation
}
}
}
}


output aiHubID string = aiHub.id
42 changes: 42 additions & 0 deletions scenarios/Agents/modules-basic-keys/basic-ai-project-keys.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Creates an Azure AI resource with proxied endpoints for the Azure AI services provider

@description('Azure region of the deployment')
param location string

@description('Tags to add to the resources')
param tags object

@description('AI Project name')
param aiProjectName string

@description('AI Project display name')
param aiProjectFriendlyName string = aiProjectName

@description('AI Project description')
param aiProjectDescription string

@description('Resource ID of the AI Hub resource')
param aiHubId string



resource aiProject 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview' = {
name: aiProjectName
location: location
tags: tags
identity: {
type: 'SystemAssigned'
}
properties: {
// organization
friendlyName: aiProjectFriendlyName
description: aiProjectDescription

// dependent resources
hubResourceId: aiHubId

}
kind: 'project'
}

output aiProjectID string = aiProject.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
@description('Azure region of the deployment')
param location string = resourceGroup().location

@description('Tags to add to the resources')
param tags object = {}

@description('AI services name')
param aiServicesName string

@description('Model name for deployment')
param modelName string

@description('Model format for deployment')
param modelFormat string

@description('Model version for deployment')
param modelVersion string

@description('Model deployment SKU name')
param modelSkuName string

@description('Model deployment capacity')
param modelCapacity int

@description('Model/AI Resource deployment location')
param modelLocation string

resource aiServices 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' = {
name: aiServicesName
location: modelLocation
sku: {
name: 'S0'
}
kind: 'AIServices' // or 'OpenAI'
identity: {
type: 'SystemAssigned'
}
properties: {
customSubDomainName: toLower('${toLower(aiServicesName)}')
apiProperties: {
statisticsEnabled: false
}
publicNetworkAccess: 'Enabled'
}
}

resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-06-01-preview'= {
parent: aiServices
name: modelName
sku : {
capacity: modelCapacity
name: modelSkuName
}
properties: {
model:{
name: modelName
format: modelFormat
version: modelVersion
}
}
}

@description('Name of the storage account')
param storageName string

@allowed([
'Standard_LRS'
'Standard_ZRS'
'Standard_GRS'
'Standard_GZRS'
'Standard_RAGRS'
'Standard_RAGZRS'
'Premium_LRS'
'Premium_ZRS'
])

@description('Storage SKU')
param storageSkuName string = 'Standard_LRS'

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

resource storage 'Microsoft.Storage/storageAccounts@2023-05-01' = {
name: storageNameCleaned
location: location
tags: tags
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: 'Deny'
}
supportsHttpsTrafficOnly: true
}
}

output aiservicesID string = aiServices.id
output aiservicesTarget string = aiServices.properties.endpoint
output storageId string = storage.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Assigns the necessary roles to the AI project

param aiSearchName string
param aiProjectPrincipalId string
param aiProjectId string

resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' existing = {
name: aiSearchName
scope: resourceGroup()
}

// search roles
resource searchIndexDataContributorRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
scope: resourceGroup()
}

resource searchIndexDataContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: searchService
name: guid(aiProjectId, searchIndexDataContributorRole.id, searchService.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: searchIndexDataContributorRole.id
principalType: 'ServicePrincipal'
}
}

resource searchServiceContributorRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '7ca78c08-252a-4471-8644-bb5ff32d4ba0'
scope: resourceGroup()
}

resource searchServiceContributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: searchService
name: guid(aiProjectId, searchServiceContributorRole.id, searchService.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: searchServiceContributorRole.id
principalType: 'ServicePrincipal'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Assigns the necessary roles to the AI project

param aiServicesName string
param aiProjectPrincipalId string
param aiProjectId string

resource aiServices 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' existing = {
name: aiServicesName
scope: resourceGroup()
}

resource cognitiveServicesContributorRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '25fbc0a9-bd7c-42a3-aa1a-3b75d497ee68'
scope: resourceGroup()

}

resource cognitiveServicesContributorAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01'= {
scope: aiServices
name: guid(aiServices.id, cognitiveServicesContributorRole.id, aiProjectId)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: cognitiveServicesContributorRole.id
principalType: 'ServicePrincipal'
}
}


resource cognitiveServicesOpenAIUserRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
scope: resourceGroup()
}
resource cognitiveServicesOpenAIUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: aiServices
name: guid(aiProjectId, cognitiveServicesOpenAIUserRole.id, aiServices.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: cognitiveServicesOpenAIUserRole.id
principalType: 'ServicePrincipal'
}
}

resource cognitiveServicesUserRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: 'a97b65f3-24c7-4388-baec-2e87135dc908'
scope: resourceGroup()
}

resource cognitiveServicesUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
scope: aiServices
name: guid(aiProjectId, cognitiveServicesUserRole.id, aiServices.id)
properties: {
principalId: aiProjectPrincipalId
roleDefinitionId: cognitiveServicesUserRole.id
principalType: 'ServicePrincipal'
}
}
Loading