Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into mg-hub-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
hatboyzero committed Jul 31, 2024
2 parents 26463ad + 0444e3e commit cc55af7
Show file tree
Hide file tree
Showing 62 changed files with 2,238 additions and 1,894 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display_name": null,
"description": null,
"cost_center": null,
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"version": "0.0",
"deployment_name": "completions",
"model_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display_name": null,
"description": null,
"cost_center": null,
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"version": "0.0",
"deployment_name": "embeddings",
"model_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"max_history": 5
},
"gatekeeper": {
"use_system_setting": false,
"use_system_setting": true,
"options": []
},
"orchestration_settings": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "api-endpoint",
"name": "AzureOpenAI",
"object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"display_name": null,
"description": null,
"cost_center": null,
Expand All @@ -13,5 +13,6 @@
"url": "${env:AZURE_OPENAI_ENDPOINT}",
"url_exceptions": [],
"timeout_seconds": 60,
"retry_strategy_name": "ExponentialBackoff"
"retry_strategy_name": "ExponentialBackoff",
"provider": "microsoft"
}
110 changes: 110 additions & 0 deletions deploy/quick-start/scripts/New-Backup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env pwsh

Param(
[Parameter(Mandatory = $true)][string]$resourceGroup,
[Parameter(Mandatory = $true)][string]$destinationStorageAccount
)

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

function Get-SearchServiceIndexes {
param(
[Parameter(Mandatory = $true)][string]$searchServiceName,
[Parameter(Mandatory = $true)][string]$pathPrefix
)

$serviceUri = "https://$searchServiceName.search.windows.net"
$uri = $serviceUri + "/indexes?api-version=2020-06-30&`$select=name"
$token = $(az account get-access-token --query accessToken --output tsv --scope "https://search.azure.com/.default")
$headers = @{"Authorization" = "Bearer $token"; "Accept" = "application/json"; "ContentType" = "application/json; charset=utf-8"}

$indexes = $(Invoke-RestMethod -Uri $uri -Method GET -Headers $headers).value.name
foreach ($index in $indexes) {
$uri = $serviceUri `
+ "/indexes/$index/docs/`$count?api-version=2020-06-30"
$req = [System.Net.WebRequest]::Create($uri)

$req.ContentType = "application/json; charset=utf-8"
$req.Accept = "application/json"
$req.Headers["Authorization"] = "Bearer $token"

$resp = $req.GetResponse()
$reader = new-object System.IO.StreamReader($resp.GetResponseStream())
$result = $reader.ReadToEnd()
$documentCount = [int]$result

$pageCount = [math]::ceiling($documentCount / 500)

$job = 1..$pageCount | ForEach-Object -Parallel {
$skip = ($_ - 1) * 500
$uri = $using:serviceUri + "/indexes/$($using:index)/docs?api-version=2020-06-30&search=*&`$skip=$($skip)&`$top=500&searchMode=all"
$outputPath = "$($using:index)_$($_).json"
Invoke-RestMethod -Uri $uri -Method GET -Headers $using:headers -ContentType "application/json" |
ConvertTo-Json -Depth 9 |
Set-Content $outputPath
"Output: $uri"
azcopy copy $outputPath "$($using:pathPrefix)/$($using:index)/"
} -ThrottleLimit 5 -AsJob
$job | Receive-Job -Wait
}
}

# Navigate to the script directory so that we can use relative paths.
Push-Location $($MyInvocation.InvocationName | Split-Path)
try {
# Create backups container
az storage container create -n backups --account-name $destinationStorageAccount

# Get main storage account
$sourceStorageAccountName = ""
foreach ($resourceId in (az storage account list -g $resourceGroup --query "@[].id" --output tsv)) {
if ((az tag list --resource-id $resourceId --query "contains(keys(@.properties.tags), 'azd-env-name')") -eq $true) {
$sourceStorageAccountName = $(az resource show --ids $resourceId --query "@.name" --output tsv)
Write-Host "Selecting $sourceStorageAccountName as the storage account"
break;
}
}

if ([string]::IsNullOrEmpty($sourceStorageAccountName)) {
throw "Could not find any storage accounts with the azd-env-name tag in $resourceGroup."
}

# Recursively copy storage account contents
$env:AZCOPY_AUTO_LOGIN_TYPE="AZCLI"
foreach ($container in (az storage container list --account-name $sourceStorageAccountName --query "@[].name" --auth-mode login -o tsv)) {
azcopy copy "https://$($sourceStorageAccountName).blob.core.windows.net/$container/" "https://$destinationStorageAccount.blob.core.windows.net/backups/$resourceGroup/" --recursive
}

$sourceSearchServiceName = ""
foreach ($resourceId in (az search service list -g $resourceGroup --query "@[].id" --output tsv)) {
if ((az tag list --resource-id $resourceId --query "contains(keys(@.properties.tags), 'azd-env-name')") -eq $true) {
$sourceSearchServiceName = $(az resource show --ids $resourceId --query "@.name" --output tsv)
Write-Host "Selecting $sourceSearchServiceName as the search service"
break;
}
}

if ([string]::IsNullOrEmpty($sourceSearchServiceName)) {
throw "Could not find any search services with the azd-env-name tag in $resourceGroup."
}

# Save Search Indexes
Get-SearchServiceIndexes -searchServiceName $sourceSearchServiceName -pathPrefix "https://$destinationStorageAccount.blob.core.windows.net/backups/$resourceGroup/data-sources/indexes"
}
catch {
if (Test-Path -Path "$env:HOME/.azcopy") {
$logFile = Get-ChildItem -Path "$env:HOME/.azcopy" -Filter "*.log" | `
Where-Object { $_.Name -notlike "*-scanning*" } | `
Sort-Object LastWriteTime -Descending | `
Select-Object -First 1
$logFileContent = Get-Content -Raw -Path $logFile.FullName
Write-Host $logFileContent
}
Write-Host $_.Exception.Message
}
finally {
Pop-Location
Set-PSDebug -Trace 0 # Echo every command (0 to disable, 1 to enable)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display_name": null,
"description": null,
"cost_center": null,
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"version": "0.0",
"deployment_name": "completions",
"model_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"display_name": null,
"description": null,
"cost_center": null,
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"endpoint_object_id": "/instances/${env:FOUNDATIONALLM_INSTANCE_ID}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"version": "0.0",
"deployment_name": "embeddings",
"model_parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"max_history": 5
},
"gatekeeper": {
"use_system_setting": false,
"use_system_setting": true,
"options": []
},
"orchestration_settings": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "api-endpoint",
"name": "AzureOpenAI",
"object_id": "/instances/{{instanceId}}/providers/FoundationaLLM.Configuration/apiEndpoints/AzureOpenAI",
"object_id": "/instances/{{instanceId}}/providers/FoundationaLLM.Configuration/apiEndpointConfigurations/AzureOpenAI",
"display_name": null,
"description": null,
"cost_center": null,
Expand All @@ -13,5 +13,6 @@
"url": "{{openAiEndpointUri}}",
"url_exceptions": [],
"timeout_seconds": 60,
"retry_strategy_name": "ExponentialBackoff"
"retry_strategy_name": "ExponentialBackoff",
"provider": "microsoft"
}
6 changes: 5 additions & 1 deletion docs/development/development-local.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,15 @@ The `CoreWorker` project is a .NET worker service that acts as the Cosmos DB cha

### Python Environment Variables

Create a local environment variable named `FOUNDATIONALLM_APP_CONFIGURATION_URI`. The value should be the URI of the Azure App Configuration service and _not_ the connection string. We use role-based access controls (RBAC) to access the Azure App Configuration service, so the connection string is not required.
Create local environment variables named:

- `FOUNDATIONALLM_APP_CONFIGURATION_URI`. The value should be the URI of the Azure App Configuration service and _not_ the connection string. We use role-based access controls (RBAC) to access the Azure App Configuration service, so the connection string is not required.
- `FOUNDATIONALLM_ENV`: This is required by the `OperationsManager` to disable the `verify` setting on requests. By setting the value to `dev`, it allows calls to the State API from LangChain and other Python-based APIs when running locally (`FOUNDATIONALLM_ENV` = `dev`) by disabling the check for a valid SSL cert on requests. This is only necessary when running the State API locally. Otherwise, the setting should be set to `prod`.

| Name | Value | Description |
| ---- | ----- | ----------- |
| FOUNDATIONALLM_APP_CONFIGURATION_URI | REDACTED | Azure App Configuration URI |
| FOUNDATIONALLM_ENV | `dev` or `prod` | Environment specification. Acceptable values are `dev` and `prod`. Defaults to `prod` if not set. |

## Running the solution locally

Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/Authorization/Services/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void AddAuthorizationCore(this IHostApplicationBuilder builder)
public static void AddAuthorizationService(this IHostApplicationBuilder builder)
{
builder.Services.AddOptions<AuthorizationServiceSettings>()
.Bind(builder.Configuration.GetSection(AppConfigurationKeySections.FoundationaLLM_APIEndpoints_AuthorizationAPI));
.Bind(builder.Configuration.GetSection(AppConfigurationKeySections.FoundationaLLM_APIEndpoints_AuthorizationAPI_Essentials));
builder.Services.AddSingleton<IAuthorizationService, AuthorizationService>();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// -------------------------------------------------------------------------------
//
// WARNING!
// This file is auto-generated based on the AuthorizationAppConfiguration.json file.
// Do not make changes to this file, as they will be automatically overwritten.
//
// -------------------------------------------------------------------------------
namespace FoundationaLLM.Common.Constants.Configuration
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
var jsonObjects = JsonNode.Parse(inputContent)!;
Func<JsonNode, string> getName = n => n.GetValue<string>().Replace(":", "_");
#>
// -------------------------------------------------------------------------------
//
// WARNING!
// This file is auto-generated based on the AuthorizationAppConfiguration.json file.
// Do not make changes to this file, as they will be automatically overwritten.
//
// -------------------------------------------------------------------------------
namespace FoundationaLLM.Common.Constants.Configuration
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// -------------------------------------------------------------------------------
//
// WARNING!
// This file is auto-generated based on the AuthorizationAppConfiguration.json file.
// Do not make changes to this file, as they will be automatically overwritten.
//
// -------------------------------------------------------------------------------
namespace FoundationaLLM.Common.Constants.Configuration
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
? n["value"].GetValue<string>()
: $"{{\\\"uri\\\":\\\"${{env:AZURE_KEY_VAULT_ENDPOINT}}secrets/foundationallm-{n["secret"].GetValue<string>()}}}\\\"}}";
#>
// -------------------------------------------------------------------------------
//
// WARNING!
// This file is auto-generated based on the AuthorizationAppConfiguration.json file.
// Do not make changes to this file, as they will be automatically overwritten.
//
// -------------------------------------------------------------------------------
namespace FoundationaLLM.Common.Constants.Configuration
{
/// <summary>
Expand Down
Loading

0 comments on commit cc55af7

Please sign in to comment.