Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
"vscode": {
"extensions": [
"ms-dotnettools.csdevkit",
"ms-vscode.vscode-typescript-next"
"ms-vscode.vscode-typescript-next",
"ms-azuretools.vscode-bicep"
]
}
},
"features": {
// See https://containers.dev/features for list of features
"ghcr.io/devcontainers/features/docker-in-docker:2": {
},
"ghcr.io/azure/azure-dev/azd:latest": {}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. azd is installed, but when I try to run there is an error about docker not being installed 🙃

}
}
6 changes: 3 additions & 3 deletions Backend/Services/SemanticKernelApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal struct SemanticKernelConfig

internal static async Task<SemanticKernelConfig> CreateAsync(ISecretStore secretStore, CancellationToken cancellationToken)
{
var useAzureOpenAI = await secretStore.GetSecretAsync("UseAzureOpenAI", cancellationToken).ContinueWith(task => bool.Parse(task.Result));
var useAzureOpenAI = await secretStore.GetSecretAsync("USE_AZURE_OPENAI", cancellationToken).ContinueWith(task => bool.Parse(task.Result));
if (useAzureOpenAI)
{
var azureDeployment = await secretStore.GetSecretAsync("AzureDeployment", cancellationToken);
var azureEndpoint = await secretStore.GetSecretAsync("AzureEndpoint", cancellationToken);
var azureDeployment = await secretStore.GetSecretAsync("AZURE_OPENAI_DEPLOYMENT", cancellationToken);
var azureEndpoint = await secretStore.GetSecretAsync("AZURE_OPENAI_ENDPOINT", cancellationToken);

return new SemanticKernelConfig
{
Expand Down
4 changes: 4 additions & 0 deletions Backend/bicep/abbreviations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"keyVaultVaults": "kv-",
"resourcesResourceGroups": "rg-"
}
49 changes: 49 additions & 0 deletions Backend/bicep/ai.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
param name string
param location string
param deployment object = {
name: 'chat'
model: {
format: 'OpenAI'
name: 'gpt-4'
version: '0613'
}
sku: {
capacity: 1
}
}

@description('')
resource azureOpenAiResource 'Microsoft.CognitiveServices/accounts@2023-10-01-preview' = {
name: name
location: location
sku: {
name: 'S0'
}
kind: 'OpenAI'
tags: {}
properties: {
customSubDomainName: name
networkAcls: {
defaultAction: 'Allow'
virtualNetworkRules: []
ipRules: []
}
publicNetworkAccess: 'Enabled'
}
}

resource modelDeployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = {
parent: azureOpenAiResource
name: deployment.name
sku: (contains(deployment.sku, 'sku') ? deployment.sku : {
name: 'Standard'
capacity: deployment.sku.capacity
})
properties: {
model: deployment.model
raiPolicyName: (contains(deployment, 'raiPolicyName') ? deployment.raiPolicyName : null)
}
}

output endpoint string = azureOpenAiResource.properties.endpoint
output deploymentName string = modelDeployment.name
56 changes: 56 additions & 0 deletions Backend/bicep/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
targetScope='subscription'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: rename "bicep" directory to "infra", align with azd standard

// The main bicep module to provision Azure resources.
// For a more complete walkthrough to understand how this file works with azd,
// see https://learn.microsoft.com/azure/developer/azure-developer-cli/make-azd-compatible?pivots=azd-create

var abbrs = loadJsonContent('./abbreviations.json')

// Optional parameters to override the default azd resource naming conventions.
// Add the following to main.parameters.json to provide values:
// "resourceGroupName": {
// "value": "myGroupName"
// }
param resourceGroupName string = ''
param azureOpenAIServiceName string = ''

@minLength(1)
@maxLength(64)
@description('Name of the environment which is used to generate a short, unique hash used in all resources.')
// For an overview on this and other key Azure concepts,
// see https://learn.microsoft.com/azure/deployment-environments/concept-environments-key-concepts#environments
param environmentName string

// tags that will be applied to all resources.
var tags = {
// Tag all resources with the environment name.
'azd-env-name': environmentName
}

@description('Location of all resources')
param location string

// Generate a unique token to be used in naming resources.
// Remove linter suppression after using.
#disable-next-line no-unused-vars
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))

// Resources are organized in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : '${abbrs.resourcesResourceGroups}${environmentName}'
location: location
tags: tags
}

module azureOpenAi 'ai.bicep' = {
name: 'azureOpenAi'
params: {
name: !empty(azureOpenAIServiceName) ? azureOpenAIServiceName : 'aoai-${resourceToken}'
location: location
}
scope: rg
}

output AZURE_OPENAI_ENDPOINT string = azureOpenAi.outputs.endpoint
output AZURE_OPENAI_DEPLOYMENT string = azureOpenAi.outputs.deploymentName
output USE_AZURE_OPENAI bool = true
24 changes: 24 additions & 0 deletions Backend/bicep/main.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
"location": {
"value": "${AZURE_LOCATION}"
},
"resourceGroupName": {
"value": "${AZURE_RESOURCE_GROUP}"
},
"openAiServiceName": {
"value": "${AZURE_OPENAI_SERVICE}"
},
"azureOpenAIEndpoint": {
"value": "${AZURE_OPENAI_ENDPOINT}"
},
"azureOpenAiDeploymentName": {
"value": "${AZURE_OPENAI_DEPLOYMENT}"
}
}
}