Skip to content

Commit

Permalink
Merge branch 'main' into cj-refactor-app-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ciprianjichici authored Jul 28, 2024
2 parents 4fd40d7 + 8744405 commit d622412
Show file tree
Hide file tree
Showing 142 changed files with 8,315 additions and 2,132 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"ResourceReferences": [
{
"Name": "AuthorizationAPI",
"Filename": "/FoundationaLLM.Configuration/AuthorizationAPI.json",
"Type": "api-endpoint",
"Deleted": false
},
{
"Name": "AzureContentSafety",
"Filename": "/FoundationaLLM.Configuration/AzureContentSafety.json",
Expand Down
14 changes: 14 additions & 0 deletions deploy/quick-start/config/appconfig.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
"content_type": "",
"tags": {}
},
{
"key": "FoundationaLLM:AIModel:ResourceProviderService:Storage:AccountName",
"value": "${env:AZURE_STORAGE_ACCOUNT_NAME}",
"label": null,
"content_type": "",
"tags": {}
},
{
"key": "FoundationaLLM:AIModel:ResourceProviderService:Storage:AuthenticationType",
"value": "AzureIdentity",
"label": null,
"content_type": "",
"tags": {}
},
{
"key": "FoundationaLLM:APIs:AgentHubAPI:APIKey",
"value": "{\"uri\":\"${env:AZURE_KEY_VAULT_ENDPOINT}secrets/foundationallm-apis-agenthubapi-apikey\"}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,8 @@
},
"orchestration_settings": {
"orchestrator": "LangChain",
"agent_parameters": null,
"endpoint_configuration": {
"auth_type": "key",
"provider": "microsoft",
"endpoint": "${env:AZURE_OPENAI_ENDPOINT}",
"api_key": "FoundationaLLM:AzureOpenAI:API:Key",
"api_version": "2023-05-15"
},
"model_parameters": {
"temperature": 0,
"deployment_name": "completions"
}
"agent_parameters": null
},
"ai_model_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.AIModel/aiModels/DefaultCompletionAIModel",
"prompt_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Prompt/prompts/FoundationaLLM"
}

This file was deleted.

10 changes: 10 additions & 0 deletions deploy/quick-start/infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,31 @@ module cosmosDb './shared/cosmosdb.bicep' = {
name: 'UserSessions'
partitionKeyPath: '/upn'
maxThroughput: 1000
defaultTtl: null
}
{
name: 'UserProfiles'
partitionKeyPath: '/upn'
maxThroughput: 1000
defaultTtl: null
}
{
name: 'Sessions'
partitionKeyPath: '/sessionId'
maxThroughput: 1000
defaultTtl: null
}
{
name: 'State'
partitionKeyPath: '/operation_id'
maxThroughput: 1000
defaultTtl: 604800
}
{
name: 'leases'
partitionKeyPath: '/id'
maxThroughput: 1000
defaultTtl: null
}
]
databaseName: 'database'
Expand Down
28 changes: 27 additions & 1 deletion deploy/quick-start/infra/shared/cosmosdb.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2023-04-15
}

resource cosmosContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2023-04-15' = [
for container in containers: {
for container in containers: if (container.defaultTtl == null) {
parent: database
name: container.name
properties: {
Expand All @@ -61,5 +61,31 @@ resource cosmosContainer 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/con
}
]

resource cosmosContainerWithTtl 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2023-04-15' = [
for container in containers: if (container.defaultTtl != null) {
parent: database
name: container.name
properties: {
resource: {
id: container.name
partitionKey: {
paths: [
container.partitionKeyPath
]
kind: 'Hash'
version: 2
}
defaultTtl: container.defaultTtl
}
options: {
autoscaleSettings: {
maxThroughput: container.maxThroughput
}
}
}
tags: tags
}
]

output endpoint string = cosmosDb.properties.documentEndpoint
output name string = cosmosDb.name
1 change: 1 addition & 0 deletions deploy/standard-hub/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.azure
5 changes: 5 additions & 0 deletions deploy/standard-hub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Deployment Configurations and Scripts

The deployment configurations and scripts are located in this `deploy` directory.
If you are looking for the deployment instructions, please refer to the [documentation](https://docs.foundationallm.ai) and it is also available in this repository in the `docs` directory as markdown files.
[Setup Guides in Markdown format](https://github.com/solliancenet/foundationallm/blob/main/docs/setup-guides/index.md)
75 changes: 75 additions & 0 deletions deploy/standard-hub/azd-hooks/postprovision.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env pwsh

Set-PSDebug -Trace 0 # Echo every command (0 to disable, 1 to enable)
Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"

# Load utility functions
Push-Location $($MyInvocation.InvocationName | Split-Path)
try {
. ./utility/Load-Utility-Functions.ps1
}
finally {
Pop-Location
}

$dnsServerIp = "${env:DNS_RESOLVER_ENDPOINT_IP}"
$outputFolderPath = "../standard-hub/config/vpn" | Get-AbsolutePath
$outputFilePath = Join-Path $outputFolderPath "VpnClientConfiguration.zip"
$resourceGroupName = "${env:RESOURCE_GROUP_NAME}"
$vpnGatewayName = "${env:VPN_GATEWAY_NAME}"
$xmlFilePath = Join-Path $outputFolderPath "AzureVPN" "azurevpnconfig.xml" # Assuming the XML file is inside the extracted folder

# Add the dns-resolver extension to the cli
az extension add --name dns-resolver --allow-preview true --yes --only-show-errors

# Get the VPN client configuration package URL
$vpnClientPackageUrl = az network vnet-gateway vpn-client generate `
--name $vpnGatewayName `
--resource-group $resourceGroupName `
--output tsv

# Download the package and extract
Invoke-WebRequest -Uri $vpnClientPackageUrl -OutFile $outputFilePath
Expand-Archive -Path $outputFilePath -DestinationPath $outputFolderPath -Force

# Assuming the XML file is directly inside the expanded folder & Read the XML file
$expandedFolder = (Get-ChildItem -Directory -Path $outputFolderPath)[0].FullName
$xmlFilePath = Join-Path -Path $expandedFolder -ChildPath "azurevpnconfig.xml"
$xmlContent = Get-Content -Path $xmlFilePath
$azureVpnClientConfig = [xml]$xmlContent

# Create a namespace manager
$namespaceManager = New-Object System.Xml.XmlNamespaceManager($azureVpnClientConfig.NameTable)
$namespaceManager.AddNamespace("ns", "http://schemas.datacontract.org/2004/07/")
$namespaceManager.AddNamespace("i", "http://www.w3.org/2001/XMLSchema-instance")

# Remove <clientconfig i:nil="true" /> node if it exists
$nilClientConfigNode = $azureVpnClientConfig.SelectSingleNode("//ns:clientconfig[@i:nil='true']", $namespaceManager)
if ($nilClientConfigNode -ne $null) {
$nilClientConfigNode.ParentNode.RemoveChild($nilClientConfigNode) | Out-Null
}

# Create DNS servers XML nodes
$dnsServersNode = $azureVpnClientConfig.CreateElement("dnsservers", "http://schemas.datacontract.org/2004/07/")
$dnsServer1 = $azureVpnClientConfig.CreateElement("dnsserver", "http://schemas.datacontract.org/2004/07/")
$dnsServer1.InnerText = $dnsServerIp
$dnsServersNode.AppendChild($dnsServer1) | Out-Null

# Locate the clientconfig node or create it if it doesn't exist
$clientConfigNode = $azureVpnClientConfig.SelectSingleNode("//ns:clientconfig", $namespaceManager)
if ($clientConfigNode -eq $null) {
$clientConfigNode = $azureVpnClientConfig.CreateElement("clientconfig", "http://schemas.datacontract.org/2004/07/")
$azureVpnClientConfig.DocumentElement.AppendChild($clientConfigNode) | Out-Null
}

# Append DNS servers to clientconfig
$clientConfigNode.AppendChild($dnsServersNode) | Out-Null

# Save the updated XML file
$azureVpnClientConfig.Save($xmlFilePath)

Write-Host -ForegroundColor Yellow `
"Please Install the Azure VPN client via https://aka.ms/azvpnclientdownload, and
then import the VPN client configuration package downloaded to $xmlFilePath. Make sure to connect
to the VPN prior to running the next step of the FLLM Install for Standard."
18 changes: 18 additions & 0 deletions deploy/standard-hub/azd-hooks/utility/Get-AbsolutePath.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /usr/bin/pwsh

Set-PSDebug -Trace 0 # Echo every command (0 to disable, 1 to enable)
Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"

function Get-AbsolutePath {
<#
.SYNOPSIS
Get the absolute path of a file or directory. Relative path does not need to exist.
#>
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)]
[string]$RelatviePath
)

return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($RelatviePath)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env pwsh

Push-Location $($MyInvocation.InvocationName | Split-Path)
try {
. ./utility/Get-AbsolutePath.ps1
}
finally {
Pop-Location
}
10 changes: 10 additions & 0 deletions deploy/standard-hub/azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json

# Name of the application.
name: foundationallm-standard-hub
hooks:
postprovision:
shell: pwsh
continueOnError: false
interactive: true
run: azd-hooks/postprovision.ps1
Loading

0 comments on commit d622412

Please sign in to comment.