Skip to content

Instantly share code, notes, and snippets.

@thdotnet
Created May 23, 2024 13:21
Show Gist options
  • Select an option

  • Save thdotnet/a597cc5295ad37532642f2c75e196bd1 to your computer and use it in GitHub Desktop.

Select an option

Save thdotnet/a597cc5295ad37532642f2c75e196bd1 to your computer and use it in GitHub Desktop.

Revisions

  1. thdotnet created this gist May 23, 2024.
    92 changes: 92 additions & 0 deletions main.bicep
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    // 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'
    }
    }
    }