Skip to content

Commit 3b7a8eb

Browse files
committed
Adding initial deployment assets
contains mongodb and azure openai resources.
1 parent e6eab0e commit 3b7a8eb

File tree

3 files changed

+204
-0
lines changed

3 files changed

+204
-0
lines changed

Labs/deploy/azuredeploy.bicep

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"value": "eastus"
7+
},
8+
"name": {
9+
"value": "mongodb-aoai"
10+
},
11+
"openAiSku": {
12+
"value": "S0"
13+
},
14+
"mongoDbUserName": {
15+
"value": "S0"
16+
},
17+
18+
"mongoDbPassword": {
19+
"value": "meye$ecr3t"
20+
}
21+
}
22+
}

Labs/deploy/deploy.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Solution deployment
2+
3+
## Prerequisites
4+
5+
- Owner on Azure subscription
6+
- Account approved for Azure OpenAI service
7+
- Azure CLI installed
8+
- Azure PowerShell installed
9+
10+
## Login to Azure
11+
12+
Open a terminal window and log in to Azure using the following command:
13+
14+
```Powershell
15+
Connect-AzAccount
16+
```
17+
18+
### Set the desired subscription (Optional)
19+
20+
If you have more than one subscription associated with your account, set the desired subscription using the following command:
21+
22+
```Powershell
23+
Set-AzContext -SubscriptionId <subscription-id>
24+
```
25+
26+
## Create resource group
27+
28+
```Powershell
29+
New-AzResourceGroup -Name mongodb-aoai-rg -Location 'eastus'
30+
```
31+
32+
## Deploy using bicep template
33+
34+
Deploy the solution resources using the following command (this will take a few minutes to run):
35+
36+
```Powershell
37+
New-AzResourceGroupDeployment -ResourceGroupName mongodb-aoai-rg -TemplateFile .\azuredeploy.bicep -TemplateParameterFile .\azuredeploy.parameters.json -c
38+
```

0 commit comments

Comments
 (0)