-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from daveRendon/staging
- Loading branch information
Showing
14 changed files
with
620 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
application-workloads/chatgpt-base-v2/azuredeploy.parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"name": { | ||
"value": "azinsider-chatgpt" | ||
}, | ||
"location": { | ||
"value": "eastus" | ||
}, | ||
"principalId": { | ||
"value": "e8cace21-41c9-4995-9ef2-aa4694cb3d8a" | ||
}, | ||
"openAiResourceName": { | ||
"value": "azinsider-OpenAI" | ||
}, | ||
"openAiResourceGroupName": { | ||
"value": "openai" | ||
}, | ||
"openAiResourceGroupLocation": { | ||
"value": "eastus" | ||
}, | ||
"openAiSkuName": { | ||
"value": "S0" | ||
}, | ||
"createRoleForUser": { | ||
"value": true | ||
}, | ||
"acaExists": { | ||
"value": false | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
application-workloads/chatgpt-base-v2/container-apps.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param identityName string | ||
param containerAppsEnvironmentName string | ||
param containerRegistryName string | ||
param serviceName string = 'aca' | ||
param exists bool | ||
param openAiDeploymentName string | ||
param openAiEndpoint string | ||
|
||
resource acaIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { | ||
name: identityName | ||
location: location | ||
} | ||
|
||
|
||
module app 'modules/container-app-upsert.bicep' = { | ||
name: '${serviceName}-container-app-module' | ||
params: { | ||
name: name | ||
location: location | ||
tags: union(tags, { 'azd-service-name': serviceName }) | ||
identityName: acaIdentity.name | ||
exists: exists | ||
containerAppsEnvironmentName: containerAppsEnvironmentName | ||
containerRegistryName: containerRegistryName | ||
env: [ | ||
{ | ||
name: 'AZURE_OPENAI_CHATGPT_DEPLOYMENT' | ||
value: openAiDeploymentName | ||
} | ||
{ | ||
name: 'AZURE_OPENAI_ENDPOINT' | ||
value: openAiEndpoint | ||
} | ||
{ | ||
name: 'RUNNING_IN_PRODUCTION' | ||
value: 'true' | ||
} | ||
{ | ||
name: 'AZURE_OPENAI_CLIENT_ID' | ||
value: acaIdentity.properties.clientId | ||
} | ||
] | ||
targetPort: 50505 | ||
} | ||
} | ||
|
||
output SERVICE_ACA_IDENTITY_PRINCIPAL_ID string = acaIdentity.properties.principalId | ||
output SERVICE_ACA_NAME string = app.outputs.name | ||
output SERVICE_ACA_URI string = app.outputs.uri | ||
output SERVICE_ACA_IMAGE_NAME string = app.outputs.imageName |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
targetScope = 'subscription' | ||
|
||
@minLength(1) | ||
@maxLength(64) | ||
@description('Name which is used to generate a short unique hash for each resource') | ||
param name string | ||
|
||
@minLength(1) | ||
@description('Primary location for all resources') | ||
param location string | ||
|
||
param modelName string = 'gpt-35-turbo' | ||
|
||
@description('Id of the user or app to assign application roles') | ||
param principalId string = 'e8cace21-41c9-4995-9ef2-aa4694cb3d8a' | ||
|
||
@description('Flag to decide where to create OpenAI role for current user') | ||
param createRoleForUser bool = false | ||
|
||
param acaExists bool = false | ||
|
||
param openAiResourceName string = '' | ||
param openAiResourceGroupName string = '' | ||
param openAiResourceGroupLocation string = '' | ||
param openAiSkuName string = '' | ||
param openAiDeploymentCapacity int = 30 | ||
|
||
var resourceToken = toLower(uniqueString(subscription().id, name, location)) | ||
var tags = { 'azd-env-name': name } | ||
|
||
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
name: '${name}-rg' | ||
location: location | ||
tags: tags | ||
} | ||
|
||
resource openAiResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = if (!empty(openAiResourceGroupName)) { | ||
name: !empty(openAiResourceGroupName) ? openAiResourceGroupName : resourceGroup.name | ||
} | ||
|
||
var prefix = '${name}-${resourceToken}' | ||
|
||
var openAiDeploymentName = 'chatgpt' | ||
module openAi 'modules/cognitive-services.bicep' = { | ||
name: 'openai' | ||
scope: openAiResourceGroup | ||
params: { | ||
name: !empty(openAiResourceName) ? openAiResourceName : '${resourceToken}-cog' | ||
location: !empty(openAiResourceGroupLocation) ? openAiResourceGroupLocation : location | ||
tags: tags | ||
sku: { | ||
name: !empty(openAiSkuName) ? openAiSkuName : 'S0' | ||
} | ||
deployments: [ | ||
{ | ||
name: openAiDeploymentName | ||
model: { | ||
format: 'OpenAI' | ||
name: modelName | ||
version: '0613' | ||
} | ||
sku: { | ||
name: 'Standard' | ||
capacity: 30 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
|
||
// Container apps host (including container registry) | ||
module containerApps 'modules/container-apps.bicep' = { | ||
name: 'container-apps' | ||
scope: resourceGroup | ||
params: { | ||
name: 'app' | ||
location: location | ||
tags: tags | ||
containerAppsEnvironmentName: '${prefix}-containerapps-env' | ||
containerRegistryName: '${replace(prefix, '-', '')}registry' | ||
} | ||
} | ||
|
||
// Container app frontend | ||
module aca 'container-apps.bicep' = { | ||
name: 'aca' | ||
scope: resourceGroup | ||
params: { | ||
name: replace('${take(prefix,19)}-ca', '--', '-') | ||
location: location | ||
tags: tags | ||
identityName: '${prefix}-id-aca' | ||
containerAppsEnvironmentName: containerApps.outputs.environmentName | ||
containerRegistryName: containerApps.outputs.registryName | ||
openAiDeploymentName: openAiDeploymentName | ||
openAiEndpoint: openAi.outputs.endpoint | ||
exists: acaExists | ||
} | ||
} | ||
|
||
|
||
module openAiRoleUser 'modules/role.bicep' = if (createRoleForUser) { | ||
scope: openAiResourceGroup | ||
name: 'openai-role-user' | ||
params: { | ||
principalId: principalId | ||
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' | ||
principalType: 'ServicePrincipal' | ||
} | ||
} | ||
|
||
|
||
module openAiRoleBackend 'modules/role.bicep' = { | ||
scope: openAiResourceGroup | ||
name: 'openai-role-backend' | ||
params: { | ||
principalId: aca.outputs.SERVICE_ACA_IDENTITY_PRINCIPAL_ID | ||
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' | ||
principalType: 'ServicePrincipal' | ||
} | ||
} | ||
|
||
output AZURE_LOCATION string = location | ||
|
||
output AZURE_OPENAI_CHATGPT_DEPLOYMENT string = openAiDeploymentName | ||
output AZURE_OPENAI_ENDPOINT string = openAi.outputs.endpoint | ||
output AZURE_OPENAI_KEY string = openAi.outputs.key | ||
output AZURE_OPENAI_RESOURCE string = openAi.outputs.name | ||
output AZURE_OPENAI_RESOURCE_GROUP string = openAiResourceGroup.name | ||
output AZURE_OPENAI_SKU_NAME string = openAi.outputs.skuName | ||
output AZURE_OPENAI_RESOURCE_GROUP_LOCATION string = openAiResourceGroup.location | ||
|
||
output SERVICE_ACA_IDENTITY_PRINCIPAL_ID string = aca.outputs.SERVICE_ACA_IDENTITY_PRINCIPAL_ID | ||
output SERVICE_ACA_NAME string = aca.outputs.SERVICE_ACA_NAME | ||
output SERVICE_ACA_URI string = aca.outputs.SERVICE_ACA_URI | ||
output SERVICE_ACA_IMAGE_NAME string = aca.outputs.SERVICE_ACA_IMAGE_NAME | ||
|
||
output AZURE_CONTAINER_ENVIRONMENT_NAME string = containerApps.outputs.environmentName | ||
output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registryLoginServer | ||
output AZURE_CONTAINER_REGISTRY_NAME string = containerApps.outputs.registryName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using 'main.bicep' | ||
|
||
param name = 'azinsider-chatgpt' | ||
param modelName = 'gpt-35-turbo' | ||
|
||
param location = 'eastus' | ||
|
||
param principalId = 'e8cace21-41c9-4995-9ef2-aa4694cb3d8a' | ||
|
||
param openAiResourceName = 'azinsider-OpenAI' | ||
|
||
param openAiResourceGroupName = 'openai' | ||
|
||
param openAiResourceGroupLocation = 'eastus' | ||
|
||
param openAiSkuName = 'S0' | ||
|
||
param createRoleForUser = true | ||
|
||
param acaExists = false |
46 changes: 46 additions & 0 deletions
46
application-workloads/chatgpt-base-v2/modules/cognitive-services.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param customSubDomainName string = name | ||
param deployments array = [] | ||
param kind string = 'OpenAI' | ||
param publicNetworkAccess string = 'Enabled' | ||
param sku object = { | ||
name: 'S0' | ||
} | ||
|
||
resource account 'Microsoft.CognitiveServices/accounts@2023-05-01' = { | ||
name: name | ||
location: location | ||
tags: tags | ||
kind: kind | ||
properties: { | ||
customSubDomainName: customSubDomainName | ||
publicNetworkAccess: publicNetworkAccess | ||
networkAcls: { | ||
defaultAction: 'Allow' | ||
} | ||
} | ||
sku: sku | ||
} | ||
|
||
@batchSize(1) | ||
resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [for deployment in deployments: { | ||
parent: account | ||
name: deployment.name | ||
properties: { | ||
model: deployment.model | ||
raiPolicyName: contains(deployment, 'raiPolicyName') ? deployment.raiPolicyName : null | ||
} | ||
sku: contains(deployment, 'sku') ? deployment.sku : { | ||
name: 'Standard' | ||
capacity: 20 | ||
} | ||
}] | ||
|
||
output endpoint string = account.properties.endpoint | ||
output id string = account.id | ||
output name string = account.name | ||
output skuName string = account.sku.name | ||
output key string = account.listKeys().key1 |
76 changes: 76 additions & 0 deletions
76
application-workloads/chatgpt-base-v2/modules/container-app-upsert.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
param name string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
|
||
param containerAppsEnvironmentName string | ||
param containerName string = 'main' | ||
param containerRegistryName string | ||
|
||
@description('Minimum number of replicas to run') | ||
@minValue(1) | ||
param containerMinReplicas int = 1 | ||
@description('Maximum number of replicas to run') | ||
@minValue(1) | ||
param containerMaxReplicas int = 10 | ||
|
||
param secrets array = [] | ||
param env array = [] | ||
param external bool = true | ||
param targetPort int = 80 | ||
param exists bool | ||
|
||
@description('User assigned identity name') | ||
param identityName string | ||
|
||
@description('Enabled Ingress for container app') | ||
param ingressEnabled bool = true | ||
|
||
// Dapr Options | ||
@description('Enable Dapr') | ||
param daprEnabled bool = false | ||
@description('Dapr app ID') | ||
param daprAppId string = containerName | ||
@allowed([ 'http', 'grpc' ]) | ||
@description('Protocol used by Dapr to connect to the app, e.g. http or grpc') | ||
param daprAppProtocol string = 'http' | ||
|
||
@description('CPU cores allocated to a single container instance, e.g. 0.5') | ||
param containerCpuCoreCount string = '0.5' | ||
|
||
@description('Memory allocated to a single container instance, e.g. 1Gi') | ||
param containerMemory string = '1.0Gi' | ||
|
||
resource existingApp 'Microsoft.App/containerApps@2022-03-01' existing = if (exists) { | ||
name: name | ||
} | ||
|
||
module app 'container-app.bicep' = { | ||
name: '${deployment().name}-update' | ||
params: { | ||
name: name | ||
location: location | ||
tags: tags | ||
identityName: identityName | ||
ingressEnabled: ingressEnabled | ||
containerName: containerName | ||
containerAppsEnvironmentName: containerAppsEnvironmentName | ||
containerRegistryName: containerRegistryName | ||
containerCpuCoreCount: containerCpuCoreCount | ||
containerMemory: containerMemory | ||
containerMinReplicas: containerMinReplicas | ||
containerMaxReplicas: containerMaxReplicas | ||
daprEnabled: daprEnabled | ||
daprAppId: daprAppId | ||
daprAppProtocol: daprAppProtocol | ||
secrets: secrets | ||
external: external | ||
env: env | ||
imageName: exists ? existingApp.properties.template.containers[0].image : '' | ||
targetPort: targetPort | ||
} | ||
} | ||
|
||
output defaultDomain string = app.outputs.defaultDomain | ||
output imageName string = app.outputs.imageName | ||
output name string = app.outputs.name | ||
output uri string = app.outputs.uri |
Oops, something went wrong.