-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
241 additions
and
3 deletions.
There are no files selected for viewing
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
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,189 @@ | ||
param config string | ||
param imageVersion string | ||
param instance string = deployment().name | ||
param location string = resourceGroup().location | ||
param openaiLocation string | ||
param tags object | ||
|
||
var prefix = instance | ||
|
||
output appUrl string = 'https://claim-ai.${acaEnv.properties.defaultDomain}' | ||
|
||
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' = { | ||
name: prefix | ||
location: location | ||
tags: tags | ||
properties: { | ||
retentionInDays: 30 | ||
sku: { | ||
name: 'PerGB2018' | ||
} | ||
} | ||
} | ||
|
||
resource acaEnv 'Microsoft.App/managedEnvironments@2023-05-01' = { | ||
name: prefix | ||
location: location | ||
tags: tags | ||
properties: { | ||
appLogsConfiguration: { | ||
destination: 'log-analytics' | ||
logAnalyticsConfiguration: { | ||
customerId: logAnalyticsWorkspace.properties.customerId | ||
sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey | ||
} | ||
} | ||
workloadProfiles: [ | ||
{ | ||
// Consumption workload profile name must be 'Consumption' | ||
name: 'Consumption' | ||
workloadProfileType: 'Consumption' | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = { | ||
name: 'claim-ai' | ||
location: location | ||
tags: tags | ||
identity: { | ||
type: 'SystemAssigned' | ||
} | ||
properties: { | ||
configuration: { | ||
activeRevisionsMode: 'Single' | ||
ingress: { | ||
external: true | ||
targetPort: 8080 | ||
} | ||
} | ||
environmentId: acaEnv.id | ||
template: { | ||
scale: { | ||
maxReplicas: 1 // TODO: The actual implementation should be able to scale, because it registers itself to the EventGrid topic | ||
minReplicas: 1 | ||
} | ||
containers: [ | ||
{ | ||
image: 'ghcr.io/clemlesne/claim-ai-phone-bot:${imageVersion}' | ||
name: 'claim-ai' | ||
env: [ | ||
{ | ||
name: 'CONFIG_JSON' | ||
value: config | ||
} | ||
{ | ||
name: 'EVENTS_DOMAIN' | ||
value: 'https://claim-ai.${acaEnv.properties.defaultDomain}' | ||
} | ||
] | ||
resources: { | ||
cpu: 1 | ||
memory: '2Gi' | ||
} | ||
probes: [ | ||
{ | ||
type: 'Liveness' | ||
httpGet: { | ||
path: '/health/liveness' | ||
port: 8080 | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = { | ||
name: replace(prefix, '-', '') | ||
location: location | ||
tags: tags | ||
sku: { | ||
name: 'Standard_ZRS' | ||
} | ||
kind: 'StorageV2' | ||
} | ||
|
||
resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2023-01-01' = { | ||
parent: storageAccount | ||
name: 'default' | ||
} | ||
|
||
resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2023-01-01' = { | ||
parent: blobService | ||
name: '$web' | ||
} | ||
|
||
resource communication 'Microsoft.Communication/CommunicationServices@2023-06-01-preview' existing = { | ||
name: prefix | ||
} | ||
|
||
resource rolEventgridContributor 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { | ||
name: '1e241071-0855-49ea-94dc-649edcd759de' | ||
} | ||
|
||
resource appAccessEventgrid 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(subscription().id, deployment().name, 'appAccessEventgrid') | ||
scope: eventgridTopic | ||
properties: { | ||
principalId: containerApp.identity.principalId | ||
principalType: 'ServicePrincipal' | ||
roleDefinitionId: rolEventgridContributor.id | ||
} | ||
} | ||
|
||
resource eventgridTopic 'Microsoft.EventGrid/systemTopics@2023-12-15-preview' = { | ||
name: prefix | ||
location: 'global' | ||
tags: tags | ||
properties: { | ||
source: communication.id | ||
topicType: 'Microsoft.Communication.CommunicationServices' | ||
} | ||
} | ||
|
||
resource roleOpenaiContributor 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = { | ||
name: 'a001fd3d-188f-4b5d-821b-7da978bf7442' | ||
} | ||
|
||
resource appAccessOpenai 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(subscription().id, deployment().name, 'appAccessOpenai') | ||
scope: cognitiveOpenai | ||
properties: { | ||
principalId: containerApp.identity.principalId | ||
principalType: 'ServicePrincipal' | ||
roleDefinitionId: roleOpenaiContributor.id | ||
} | ||
} | ||
|
||
resource cognitiveOpenai 'Microsoft.CognitiveServices/accounts@2023-10-01-preview' = { | ||
name: '${prefix}-openai' | ||
location: openaiLocation | ||
tags: tags | ||
sku: { | ||
name: 'S0' | ||
} | ||
kind: 'OpenAI' | ||
properties: { | ||
customSubDomainName: '${prefix}-openai' | ||
} | ||
} | ||
|
||
resource gpt 'Microsoft.CognitiveServices/accounts/deployments@2023-10-01-preview' = { | ||
parent: cognitiveOpenai | ||
name: 'gpt-4-turbo' | ||
sku: { | ||
capacity: 50 | ||
name: 'Standard' | ||
} | ||
properties: { | ||
model: { | ||
format: 'OpenAI' | ||
name: 'gpt-4' | ||
version: '1106-Preview' | ||
} | ||
} | ||
} |
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,35 @@ | ||
param config string | ||
param imageVersion string = 'develop' | ||
param instance string = deployment().name | ||
param location string = 'westeurope' | ||
param openaiLocation string = 'swedencentral' | ||
|
||
targetScope = 'subscription' | ||
|
||
output appUrl string = app.outputs.appUrl | ||
|
||
var tags = { | ||
application: 'claim-ai' | ||
instance: instance | ||
managed_by: 'Bicep' | ||
sources: 'https://github.com/clemlesne/claim-ai-phone-bot' | ||
version: imageVersion | ||
} | ||
|
||
resource sub 'Microsoft.Resources/resourceGroups@2021-04-01' = { | ||
location: location | ||
name: instance | ||
tags: tags | ||
} | ||
|
||
module app 'app.bicep' = { | ||
name: instance | ||
scope: sub | ||
params: { | ||
config: config | ||
imageVersion: imageVersion | ||
location: location | ||
openaiLocation: openaiLocation | ||
tags: tags | ||
} | ||
} |
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