|
| 1 | +@description('Location where all resources will be deployed. This value defaults to the **East US** region.') |
| 2 | +@allowed([ |
| 3 | + 'eastus' |
| 4 | + 'francecentral' |
| 5 | + 'southcentralus' |
| 6 | + 'uksouth' |
| 7 | + 'westeurope' |
| 8 | +]) |
| 9 | +param location string = 'eastus' |
| 10 | + |
| 11 | +@description(''' |
| 12 | +Unique name for the deployed services below. Max length 15 characters, alphanumeric only: |
| 13 | +- Azure Cosmos DB for MongoDB vCore |
| 14 | +- Azure OpenAI Service |
| 15 | +
|
| 16 | +The name defaults to a unique string generated from the resource group identifier. |
| 17 | +''') |
| 18 | +@maxLength(15) |
| 19 | +param name string = uniqueString(resourceGroup().id) |
| 20 | + |
| 21 | +@description('Specifies the SKU for the Azure OpenAI resource. Defaults to **S0**') |
| 22 | +@allowed([ |
| 23 | + 'S0' |
| 24 | +]) |
| 25 | +param openAiSku string = 'S0' |
| 26 | + |
| 27 | +@description('MongoDB vCore user Name. No dashes.') |
| 28 | +param mongoDbUserName string |
| 29 | + |
| 30 | +@description('MongoDB vCore password. 8-256 characters, 3 of the following: lower case, upper case, numeric, symbol.') |
| 31 | +@minLength(8) |
| 32 | +@maxLength(256) |
| 33 | +@secure() |
| 34 | +param mongoDbPassword string |
| 35 | + |
| 36 | +var openAiSettings = { |
| 37 | + name: '${name}-openai' |
| 38 | + sku: openAiSku |
| 39 | + maxConversationTokens: '100' |
| 40 | + maxCompletionTokens: '500' |
| 41 | + completionsModel: { |
| 42 | + name: 'gpt-35-turbo' |
| 43 | + version: '0301' |
| 44 | + deployment: { |
| 45 | + name: 'completions' |
| 46 | + } |
| 47 | + } |
| 48 | + embeddingsModel: { |
| 49 | + name: 'text-embedding-ada-002' |
| 50 | + version: '2' |
| 51 | + deployment: { |
| 52 | + name: 'embeddings' |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +var mongovCoreSettings = { |
| 58 | + mongoClusterName: '${name}-mongo' |
| 59 | + mongoClusterLogin: mongoDbUserName |
| 60 | + mongoClusterPassword: mongoDbPassword |
| 61 | +} |
| 62 | + |
| 63 | +resource mongoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = { |
| 64 | + name: mongovCoreSettings.mongoClusterName |
| 65 | + location: location |
| 66 | + properties: { |
| 67 | + administratorLogin: mongovCoreSettings.mongoClusterLogin |
| 68 | + administratorLoginPassword: mongovCoreSettings.mongoClusterPassword |
| 69 | + serverVersion: '5.0' |
| 70 | + nodeGroupSpecs: [ |
| 71 | + { |
| 72 | + kind: 'Shard' |
| 73 | + sku: 'M30' |
| 74 | + diskSizeGB: 128 |
| 75 | + enableHa: false |
| 76 | + nodeCount: 1 |
| 77 | + } |
| 78 | + ] |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +resource mongoFirewallRulesAllowAzure 'Microsoft.DocumentDB/mongoClusters/firewallRules@2023-03-01-preview' = { |
| 83 | + parent: mongoCluster |
| 84 | + name: 'allowAzure' |
| 85 | + properties: { |
| 86 | + startIpAddress: '0.0.0.0' |
| 87 | + endIpAddress: '0.0.0.0' |
| 88 | + } |
| 89 | +} |
| 90 | + |
| 91 | +resource mongoFirewallRulesAllowAll 'Microsoft.DocumentDB/mongoClusters/firewallRules@2023-03-01-preview' = { |
| 92 | + parent: mongoCluster |
| 93 | + name: 'allowAll' |
| 94 | + properties: { |
| 95 | + startIpAddress: '0.0.0.0' |
| 96 | + endIpAddress: '255.255.255.255' |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +resource openAiAccount 'Microsoft.CognitiveServices/accounts@2022-12-01' = { |
| 101 | + name: openAiSettings.name |
| 102 | + location: location |
| 103 | + sku: { |
| 104 | + name: openAiSettings.sku |
| 105 | + } |
| 106 | + kind: 'OpenAI' |
| 107 | + properties: { |
| 108 | + customSubDomainName: openAiSettings.name |
| 109 | + publicNetworkAccess: 'Enabled' |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +resource openAiEmbeddingsModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = { |
| 114 | + parent: openAiAccount |
| 115 | + name: openAiSettings.embeddingsModel.deployment.name |
| 116 | + properties: { |
| 117 | + model: { |
| 118 | + format: 'OpenAI' |
| 119 | + name: openAiSettings.embeddingsModel.name |
| 120 | + version: openAiSettings.embeddingsModel.version |
| 121 | + } |
| 122 | + scaleSettings: { |
| 123 | + scaleType: 'Standard' |
| 124 | + } |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +resource openAiCompletionsModelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2022-12-01' = { |
| 129 | + parent: openAiAccount |
| 130 | + name: openAiSettings.completionsModel.deployment.name |
| 131 | + properties: { |
| 132 | + model: { |
| 133 | + format: 'OpenAI' |
| 134 | + name: openAiSettings.completionsModel.name |
| 135 | + version: openAiSettings.completionsModel.version |
| 136 | + } |
| 137 | + scaleSettings: { |
| 138 | + scaleType: 'Standard' |
| 139 | + } |
| 140 | + } |
| 141 | + dependsOn: [ |
| 142 | + openAiEmbeddingsModelDeployment |
| 143 | + ] |
| 144 | +} |
0 commit comments