-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathskillabledeploy.bicep
More file actions
161 lines (142 loc) · 5.1 KB
/
Copy pathskillabledeploy.bicep
File metadata and controls
161 lines (142 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
param labInstanceTag string
@description('Location for all resources.')
param location string = resourceGroup().location
@description('Unique name for the Azure Database for PostgreSQL.')
param serverName string = 'psql-learn-${labInstanceTag}'
@description('The version of PostgreSQL to use.')
param postgresVersion string = '16'
@description('Login name of the database administrator.')
@minLength(1)
param adminLogin string = 'pgAdmin'
@description('Password for the database administrator.')
@minLength(8)
@secure()
param adminLoginPassword string
@description('Unique name for the Azure OpenAI service.')
param azureOpenAIServiceName string = 'oai-learn-${labInstanceTag}'
@description('Unique name for the Azure AI Language service account.')
param languageServiceName string = 'lang-learn-${labInstanceTag}'
@description('Restore the service instead of creating a new instance. This is useful if you previously soft-delted the service and want to restore it. If you are restoring a service, set this to true. Otherwise, leave this as false.')
param restore bool = false
@description('Creates a PostgreSQL Flexible Server.')
resource postgreSQLFlexibleServer 'Microsoft.DBforPostgreSQL/flexibleServers@2023-03-01-preview' = {
name: serverName
location: location
sku: {
name: 'Standard_D2ds_v4'
tier: 'GeneralPurpose'
}
properties: {
administratorLogin: adminLogin
administratorLoginPassword: adminLoginPassword
authConfig: {
activeDirectoryAuth: 'Disabled'
passwordAuth: 'Enabled'
tenantId: subscription().tenantId
}
backup: {
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
}
createMode: 'Default'
highAvailability: {
mode: 'Disabled'
}
storage: {
autoGrow: 'Disabled'
storageSizeGB: 32
tier: 'P10'
}
version: postgresVersion
}
}
@description('Firewall rule that checks the "Allow public access from any Azure service within Azure to this server" box.')
resource allowAllAzureServicesAndResourcesWithinAzureIps 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2023-03-01-preview' = {
name: 'AllowAllAzureServicesAndResourcesWithinAzureIps'
parent: postgreSQLFlexibleServer
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
}
@description('Firewall rule to allow all IP addresses to connect to the server. Should only be used for lab purposes.')
resource allowAll 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2023-03-01-preview' = {
name: 'AllowAll'
parent: postgreSQLFlexibleServer
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '255.255.255.255'
}
}
@description('Creates the "rentals" database in the PostgreSQL Flexible Server.')
resource rentalsDatabase 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2023-03-01-preview' = {
name: 'rentals'
parent: postgreSQLFlexibleServer
properties: {
charset: 'UTF8'
collation: 'en_US.UTF8'
}
}
@description('Configures the "azure.extensions" parameter to allowlist extensions.')
resource allowlistExtensions 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2023-03-01-preview' = {
name: 'azure.extensions'
parent: postgreSQLFlexibleServer
dependsOn: [allowAllAzureServicesAndResourcesWithinAzureIps, allowAll, rentalsDatabase] // Ensure the database is created and configured before setting the parameter, as it requires a "restart."
properties: {
source: 'user-override'
value: 'azure_ai,vector'
}
}
@description('Creates an Azure OpenAI service.')
resource azureOpenAIService 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
name: azureOpenAIServiceName
location: location
kind: 'OpenAI'
sku: {
name: 'S0'
tier: 'Standard'
}
properties: {
customSubDomainName: azureOpenAIServiceName
publicNetworkAccess: 'Enabled'
restore: restore
}
}
@description('Creates an embedding deployment for the Azure OpenAI service.')
resource azureOpenAIEmbeddingDeployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = {
name: 'embedding'
parent: azureOpenAIService
sku: {
name: 'Standard'
capacity: 30
}
properties: {
model: {
name: 'text-embedding-ada-002'
version: '2'
format: 'OpenAI'
}
}
}
@description('Creates an Azure AI Language service account.')
resource languageService 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
name: languageServiceName
location: location
kind: 'TextAnalytics'
sku: {
name: 'S'
}
properties: {
customSubDomainName: languageServiceName
publicNetworkAccess: 'Enabled'
restore: restore
}
}
output serverFqdn string = postgreSQLFlexibleServer.properties.fullyQualifiedDomainName
output serverName string = postgreSQLFlexibleServer.name
output databaseName string = rentalsDatabase.name
output azureOpenAIServiceName string = azureOpenAIService.name
output azureOpenAIEndpoint string = azureOpenAIService.properties.endpoint
output azureOpenAIEmbeddingDeploymentName string = azureOpenAIEmbeddingDeployment.name
output languageServiceName string = languageService.name
output languageServiceEndpoint string = languageService.properties.endpoint