Skip to content

Commit c58e7af

Browse files
Merge pull request #3 from sophia-ramsey/sophia/add-bicep
Sophia/add bicep
2 parents 362e89f + db53e99 commit c58e7af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+5613
-564
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To achieve this, when users submit a message to the web server, the web server w
5858
5. Start the services with this command:
5959

6060
```shell
61-
python -m quart --app src.quartapp run --port 50505 --reload
61+
python -m uvicorn "api.main:create_app" --app-dir src --port 50505 --reload
6262
```
6363

6464
6. Click 'http://localhost:50505' in the browser to run the application.

azure.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
# TODO: do we need hooks?
3+
# TODO: do we need all of the variables?
4+
5+
name: azd-aistudio-starter
6+
metadata:
7+
8+
9+
services:
10+
api:
11+
project: ./src
12+
language: py
13+
host: containerapp
14+
docker:
15+
remoteBuild: true
16+
17+
hooks:
18+
postprovision:
19+
windows:
20+
shell: pwsh
21+
run: ./scripts/write_env.ps1
22+
continueOnError: true
23+
interactive: true
24+
posix:
25+
shell: sh
26+
run: ./scripts/write_env.sh
27+
continueOnError: true
28+
interactive: true
29+
30+
pipeline:
31+
variables:
32+
- AZURE_RESOURCE_GROUP
33+
- AZURE_AIHUB_NAME
34+
- AZURE_AIPROJECT_NAME
35+
- AZURE_AISERVICES_NAME
36+
- AZURE_SEARCH_SERVICE_NAME
37+
- AZURE_APPLICATION_INSIGHTS_NAME
38+
- AZURE_CONTAINER_REGISTRY_NAME
39+
- AZURE_KEYVAULT_NAME
40+
- AZURE_STORAGE_ACCOUNT_NAME
41+
- AZURE_LOG_ANALYTICS_WORKSPACE_NAME
42+
- USE_CONTAINER_REGISTRY
43+
- USE_APPLICATION_INSIGHTS
44+
- USE_SEARCH_SERVICE
45+
- AZURE_AI_CHAT_DEPLOYMENT_NAME
46+
- AZURE_AI_CHAT_DEPLOYMENT_SKU
47+
- AZURE_AI_CHAT_DEPLOYMENT_CAPACITY
48+
- AZURE_AI_CHAT_MODEL_NAME
49+
- AZURE_AI_CHAT_MODEL_FORMAT
50+
- AZURE_AI_CHAT_MODEL_VERSION
51+
- AZURE_AI_EMBED_DEPLOYMENT_NAME
52+
- AZURE_AI_EMBED_DEPLOYMENT_SKU
53+
- AZURE_AI_EMBED_DEPLOYMENT_CAPACITY
54+
- AZURE_AI_EMBED_MODEL_NAME
55+
- AZURE_AI_EMBED_MODEL_FORMAT
56+
- AZURE_AI_EMBED_MODEL_VERSION
57+
- AZURE_EXISTING_AIPROJECT_CONNECTION_STRING

infra/abbreviations.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"analysisServicesServers": "as",
3+
"apiManagementService": "apim-",
4+
"appConfigurationStores": "appcs-",
5+
"appManagedEnvironments": "cae-",
6+
"appContainerApps": "ca-",
7+
"authorizationPolicyDefinitions": "policy-",
8+
"automationAutomationAccounts": "aa-",
9+
"blueprintBlueprints": "bp-",
10+
"blueprintBlueprintsArtifacts": "bpa-",
11+
"cacheRedis": "redis-",
12+
"cdnProfiles": "cdnp-",
13+
"cdnProfilesEndpoints": "cdne-",
14+
"cognitiveServicesAccounts": "cog-",
15+
"cognitiveServicesFormRecognizer": "cog-fr-",
16+
"cognitiveServicesTextAnalytics": "cog-ta-",
17+
"computeAvailabilitySets": "avail-",
18+
"computeCloudServices": "cld-",
19+
"computeDiskEncryptionSets": "des",
20+
"computeDisks": "disk",
21+
"computeDisksOs": "osdisk",
22+
"computeGalleries": "gal",
23+
"computeSnapshots": "snap-",
24+
"computeVirtualMachines": "vm",
25+
"computeVirtualMachineScaleSets": "vmss-",
26+
"containerInstanceContainerGroups": "ci",
27+
"containerRegistryRegistries": "cr",
28+
"containerServiceManagedClusters": "aks-",
29+
"databricksWorkspaces": "dbw-",
30+
"dataFactoryFactories": "adf-",
31+
"dataLakeAnalyticsAccounts": "dla",
32+
"dataLakeStoreAccounts": "dls",
33+
"dataMigrationServices": "dms-",
34+
"dBforMySQLServers": "mysql-",
35+
"dBforPostgreSQLServers": "psql-",
36+
"devicesIotHubs": "iot-",
37+
"devicesProvisioningServices": "provs-",
38+
"devicesProvisioningServicesCertificates": "pcert-",
39+
"documentDBDatabaseAccounts": "cosmos-",
40+
"eventGridDomains": "evgd-",
41+
"eventGridDomainsTopics": "evgt-",
42+
"eventGridEventSubscriptions": "evgs-",
43+
"eventHubNamespaces": "evhns-",
44+
"eventHubNamespacesEventHubs": "evh-",
45+
"hdInsightClustersHadoop": "hadoop-",
46+
"hdInsightClustersHbase": "hbase-",
47+
"hdInsightClustersKafka": "kafka-",
48+
"hdInsightClustersMl": "mls-",
49+
"hdInsightClustersSpark": "spark-",
50+
"hdInsightClustersStorm": "storm-",
51+
"hybridComputeMachines": "arcs-",
52+
"insightsActionGroups": "ag-",
53+
"insightsComponents": "appi-",
54+
"keyVaultVaults": "kv-",
55+
"kubernetesConnectedClusters": "arck",
56+
"kustoClusters": "dec",
57+
"kustoClustersDatabases": "dedb",
58+
"loadTesting": "lt-",
59+
"logicIntegrationAccounts": "ia-",
60+
"logicWorkflows": "logic-",
61+
"machineLearningServicesWorkspaces": "mlw-",
62+
"managedIdentityUserAssignedIdentities": "id-",
63+
"managementManagementGroups": "mg-",
64+
"migrateAssessmentProjects": "migr-",
65+
"networkApplicationGateways": "agw-",
66+
"networkApplicationSecurityGroups": "asg-",
67+
"networkAzureFirewalls": "afw-",
68+
"networkBastionHosts": "bas-",
69+
"networkConnections": "con-",
70+
"networkDnsZones": "dnsz-",
71+
"networkExpressRouteCircuits": "erc-",
72+
"networkFirewallPolicies": "afwp-",
73+
"networkFirewallPoliciesWebApplication": "waf",
74+
"networkFirewallPoliciesRuleGroups": "wafrg",
75+
"networkFrontDoors": "fd-",
76+
"networkFrontdoorWebApplicationFirewallPolicies": "fdfp-",
77+
"networkLoadBalancersExternal": "lbe-",
78+
"networkLoadBalancersInternal": "lbi-",
79+
"networkLoadBalancersInboundNatRules": "rule-",
80+
"networkLocalNetworkGateways": "lgw-",
81+
"networkNatGateways": "ng-",
82+
"networkNetworkInterfaces": "nic-",
83+
"networkNetworkSecurityGroups": "nsg-",
84+
"networkNetworkSecurityGroupsSecurityRules": "nsgsr-",
85+
"networkNetworkWatchers": "nw-",
86+
"networkPrivateDnsZones": "pdnsz-",
87+
"networkPrivateLinkServices": "pl-",
88+
"networkPublicIPAddresses": "pip-",
89+
"networkPublicIPPrefixes": "ippre-",
90+
"networkRouteFilters": "rf-",
91+
"networkRouteTables": "rt-",
92+
"networkRouteTablesRoutes": "udr-",
93+
"networkTrafficManagerProfiles": "traf-",
94+
"networkVirtualNetworkGateways": "vgw-",
95+
"networkVirtualNetworks": "vnet-",
96+
"networkVirtualNetworksSubnets": "snet-",
97+
"networkVirtualNetworksVirtualNetworkPeerings": "peer-",
98+
"networkVirtualWans": "vwan-",
99+
"networkVpnGateways": "vpng-",
100+
"networkVpnGatewaysVpnConnections": "vcn-",
101+
"networkVpnGatewaysVpnSites": "vst-",
102+
"notificationHubsNamespaces": "ntfns-",
103+
"notificationHubsNamespacesNotificationHubs": "ntf-",
104+
"operationalInsightsWorkspaces": "log-",
105+
"portalDashboards": "dash-",
106+
"powerBIDedicatedCapacities": "pbi-",
107+
"purviewAccounts": "pview-",
108+
"recoveryServicesVaults": "rsv-",
109+
"resourcesResourceGroups": "rg-",
110+
"searchSearchServices": "srch-",
111+
"serviceBusNamespaces": "sb-",
112+
"serviceBusNamespacesQueues": "sbq-",
113+
"serviceBusNamespacesTopics": "sbt-",
114+
"serviceEndPointPolicies": "se-",
115+
"serviceFabricClusters": "sf-",
116+
"signalRServiceSignalR": "sigr",
117+
"sqlManagedInstances": "sqlmi-",
118+
"sqlServers": "sql-",
119+
"sqlServersDataWarehouse": "sqldw-",
120+
"sqlServersDatabases": "sqldb-",
121+
"sqlServersDatabasesStretch": "sqlstrdb-",
122+
"storageStorageAccounts": "st",
123+
"storageStorageAccountsVm": "stvm",
124+
"storSimpleManagers": "ssimp",
125+
"streamAnalyticsCluster": "asa-",
126+
"synapseWorkspaces": "syn",
127+
"synapseWorkspacesAnalyticsWorkspaces": "synw",
128+
"synapseWorkspacesSqlPoolsDedicated": "syndp",
129+
"synapseWorkspacesSqlPoolsSpark": "synsp",
130+
"timeSeriesInsightsEnvironments": "tsi-",
131+
"webServerFarms": "plan-",
132+
"webSitesAppService": "app-",
133+
"webSitesAppServiceEnvironment": "ase-",
134+
"webSitesFunctions": "func-",
135+
"webStaticSites": "stapp-"
136+
}

infra/api.bicep

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
param name string
2+
param location string = resourceGroup().location
3+
param tags object = {}
4+
5+
param identityName string
6+
param containerAppsEnvironmentName string
7+
param containerRegistryName string
8+
param serviceName string = 'api'
9+
param exists bool
10+
param projectConnectionString string
11+
param chatDeploymentName string
12+
13+
resource apiIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
14+
name: identityName
15+
location: location
16+
}
17+
18+
var env = [
19+
{
20+
name: 'AZURE_CLIENT_ID'
21+
value: apiIdentity.properties.clientId
22+
}
23+
{
24+
name: 'AZURE_AIPROJECT_CONNECTION_STRING'
25+
value: projectConnectionString
26+
}
27+
{
28+
name: 'AZURE_AI_CHAT_DEPLOYMENT_NAME'
29+
value: chatDeploymentName
30+
}
31+
{
32+
name: 'RUNNING_IN_PRODUCTION'
33+
value: 'true'
34+
}
35+
]
36+
37+
module app 'core/host/container-app-upsert.bicep' = {
38+
name: '${serviceName}-container-app-module'
39+
params: {
40+
name: name
41+
location: location
42+
tags: union(tags, { 'azd-service-name': serviceName })
43+
identityName: apiIdentity.name
44+
exists: exists
45+
containerAppsEnvironmentName: containerAppsEnvironmentName
46+
containerRegistryName: containerRegistryName
47+
targetPort: 50505
48+
env: env
49+
}
50+
}
51+
52+
output SERVICE_API_IDENTITY_PRINCIPAL_ID string = apiIdentity.properties.principalId
53+
output SERVICE_API_NAME string = app.outputs.name
54+
output SERVICE_API_URI string = app.outputs.uri
55+
output SERVICE_API_IMAGE_NAME string = app.outputs.imageName

infra/core/ai/cognitiveservices.bicep

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
metadata description = 'Creates an Azure Cognitive Services instance.'
2+
param name string
3+
param location string = resourceGroup().location
4+
param tags object = {}
5+
@description('The custom subdomain name used to access the API. Defaults to the value of the name parameter.')
6+
param customSubDomainName string = name
7+
param disableLocalAuth bool = false
8+
param deployments array = []
9+
param kind string = 'OpenAI'
10+
//param kind string = 'AIServices'
11+
12+
@allowed([ 'Enabled', 'Disabled' ])
13+
param publicNetworkAccess string = 'Enabled'
14+
param sku object = {
15+
name: 'S0'
16+
}
17+
18+
param allowedIpRules array = []
19+
param networkAcls object = empty(allowedIpRules) ? {
20+
defaultAction: 'Allow'
21+
} : {
22+
ipRules: allowedIpRules
23+
defaultAction: 'Deny'
24+
}
25+
26+
resource account 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
27+
name: name
28+
location: location
29+
tags: tags
30+
kind: kind
31+
properties: {
32+
customSubDomainName: customSubDomainName
33+
publicNetworkAccess: publicNetworkAccess
34+
networkAcls: networkAcls
35+
disableLocalAuth: disableLocalAuth
36+
}
37+
sku: sku
38+
}
39+
40+
@batchSize(1)
41+
resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for deployment in deployments: {
42+
parent: account
43+
name: deployment.name
44+
properties: {
45+
model: deployment.model
46+
raiPolicyName: contains(deployment, 'raiPolicyName') ? deployment.raiPolicyName : null
47+
}
48+
sku: contains(deployment, 'sku') ? deployment.sku : {
49+
name: 'Standard'
50+
capacity: 20
51+
}
52+
}]
53+
54+
output endpoint string = account.properties.endpoint
55+
output endpoints object = account.properties.endpoints
56+
output id string = account.id
57+
output name string = account.name

0 commit comments

Comments
 (0)