Skip to content

Instantly share code, notes, and snippets.

@thdotnet
Created May 23, 2024 13:21
Show Gist options
  • Save thdotnet/a597cc5295ad37532642f2c75e196bd1 to your computer and use it in GitHub Desktop.
Save thdotnet/a597cc5295ad37532642f2c75e196bd1 to your computer and use it in GitHub Desktop.
bicep file to create azure search + storage account + open ai service
// Variables
var location = 'eastus'
var storageAccountName = 'yourstorageaccountname' // Change to a unique name
var searchServiceName = 'yoursearchservicename' // Change to a unique name
var openAIServiceName = 'youropenaiservicename' // Change to a unique name
// Storage Account
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
// Azure AI Search Service
resource searchService 'Microsoft.Search/searchServices@2020-08-01' = {
name: searchServiceName
location: location
sku: {
name: 'standard'
}
properties: {
partitionCount: 1
replicaCount: 1
}
}
// Azure OpenAI Service
resource openAIService 'Microsoft.CognitiveServices/accounts@2017-04-18' = {
name: openAIServiceName
location: location
kind: 'OpenAI'
sku: {
name: 'S0'
tier: 'Standard'
}
properties: {
apiProperties: {
qnaRuntimeEndpoint: 'https://{your-qna-runtime-endpoint}'
}
}
}
// Indexer (connects Azure AI Search to the Storage Account)
resource dataSource 'Microsoft.Search/searchServices/dataSources@2020-08-01' = {
name: 'myDataSource'
parent: searchService
properties: {
type: 'azureblob'
credentials: {
connectionString: storageAccount.properties.primaryEndpoints.blob
}
container: {
name: 'files'
}
}
}
resource index 'Microsoft.Search/searchServices/indexes@2020-08-01' = {
name: 'myIndex'
parent: searchService
properties: {
fields: [
{
name: 'id'
type: 'Edm.String'
key: true
}
{
name: 'content'
type: 'Edm.String'
}
]
}
}
resource indexer 'Microsoft.Search/searchServices/indexers@2020-08-01' = {
name: 'myIndexer'
parent: searchService
properties: {
dataSourceName: dataSource.name
targetIndexName: index.name
schedule: {
interval: 'PT1H'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment