diff --git a/.github/workflows/deploy-waf.yml b/.github/workflows/deploy-waf.yml index b97c51d0d..1eafde847 100644 --- a/.github/workflows/deploy-waf.yml +++ b/.github/workflows/deploy-waf.yml @@ -101,8 +101,10 @@ jobs: az deployment group create \ --resource-group ${{ env.RESOURCE_GROUP_NAME }} \ --template-file infra/main.bicep \ - --parameters infra/main.waf-aligned.bicepparam \ - --parameters azureOpenAILocation=${{ env.AZURE_LOCATION }} + --parameters \ + azureOpenAILocation='${{ env.AZURE_LOCATION }}' \ + virtualMachineConfiguration='{"adminUsername": "adminuser", "adminPassword": "P@ssw0rd1234"}' \ + logAnalyticsWorkspaceConfiguration='{"existingWorkspaceResourceId": ""}' - name: Send Notification on Failure diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 08d596791..5559aa905 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -101,8 +101,12 @@ jobs: az deployment group create \ --resource-group ${{ env.RESOURCE_GROUP_NAME }} \ --template-file infra/main.bicep \ - --parameters infra/main.bicepparam \ - --parameters azureOpenAILocation=${{ env.AZURE_LOCATION }} + --parameters \ + azureOpenAILocation='${{ env.AZURE_LOCATION }}' \ + logAnalyticsWorkspaceConfiguration='{"dataRetentionInDays": 30, "existingWorkspaceResourceId": ""}' \ + applicationInsightsConfiguration='{"retentionInDays": 30}' \ + virtualNetworkConfiguration='{"enabled": false}' \ + webServerFarmConfiguration='{"skuCapacity": 1, "skuName": "B2"}' - name: Send Notification on Failure diff --git a/azure.yaml b/azure.yaml index 5a212cb3d..ee4810b1c 100644 --- a/azure.yaml +++ b/azure.yaml @@ -1,20 +1,4 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json name: multi-agent-custom-automation-engine-solution-accelerator metadata: - template: multi-agent-custom-automation-engine-solution-accelerator@1.0 -hooks: - preprovision: - posix: - shell: sh - run: > - chmod u+r+x ./infra/scripts/validate_model_deployment_quota.sh; chmod u+r+x ./infra/scripts/validate_model_quota.sh; ./infra/scripts/validate_model_deployment_quota.sh --subscription "$AZURE_SUBSCRIPTION_ID" --location "${AZURE_ENV_OPENAI_LOCATION:-swedencentral}" --models-parameter "aiModelDeployments" - interactive: false - continueOnError: false - - windows: - shell: pwsh - run: > - $location = if ($env:AZURE_ENV_OPENAI_LOCATION) { $env:AZURE_ENV_OPENAI_LOCATION } else { "swedencentral" }; - ./infra/scripts/validate_model_deployment_quotas.ps1 -SubscriptionId $env:AZURE_SUBSCRIPTION_ID -Location $location -ModelsParameter "aiModelDeployments" - interactive: false - continueOnError: false \ No newline at end of file + template: multi-agent-custom-automation-engine-solution-accelerator@1.0 \ No newline at end of file diff --git a/docs/CustomizingAzdParameters.md b/docs/CustomizingAzdParameters.md index b4e194726..2dab381d9 100644 --- a/docs/CustomizingAzdParameters.md +++ b/docs/CustomizingAzdParameters.md @@ -16,7 +16,7 @@ By default this template will use the environment name as the prefix to prevent | `AZURE_ENV_MODEL_VERSION` | string | `2024-08-06` | Version of the GPT model to be used for deployment. | | `AZURE_ENV_IMAGETAG` | string | `latest` | Docker image tag used for container deployments. | | `AZURE_ENV_ENABLE_TELEMETRY` | bool | `true` | Enables telemetry for monitoring and diagnostics. | - +| `AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID` | string | `` | Set this if you want to reuse an existing Log Analytics Workspace instead of creating a new one. | --- ## How to Set a Parameter @@ -27,6 +27,11 @@ To customize any of the above values, run the following command **before** `azd azd env set ``` +Set the Log Analytics Workspace Id if you need to reuse the existing workspace which is already existing +```shell +azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '/subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/' +``` + **Example:** ```bash diff --git a/docs/DeploymentGuide.md b/docs/DeploymentGuide.md index c45603940..5fc6337d0 100644 --- a/docs/DeploymentGuide.md +++ b/docs/DeploymentGuide.md @@ -318,7 +318,7 @@ The files for the dev container are located in `/.devcontainer/` folder. ``` ```bash - az role assignment create --assignee --role "Cognitive Services OpenAI User" --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ + az role assignment create --assignee --role "Azure AI User" --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ ``` **Using a Different Database in Cosmos:** @@ -353,7 +353,7 @@ The files for the dev container are located in `/.devcontainer/` folder. - From the src/backend directory: ```bash -python app.py +python app_kernel.py ``` - In a new terminal from the src/frontend directory diff --git a/docs/LocalDeployment.md b/docs/LocalDeployment.md index a34ba5837..da1eb1415 100644 --- a/docs/LocalDeployment.md +++ b/docs/LocalDeployment.md @@ -92,7 +92,7 @@ The files for the dev container are located in `/.devcontainer/` folder. ``` ```bash - az role assignment create --assignee --role "Cognitive Services OpenAI User" --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ + az role assignment create --assignee --role "Azure AI User" --scope /subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts/ ``` **Using a Different Database in Cosmos:** @@ -123,7 +123,7 @@ The files for the dev container are located in `/.devcontainer/` folder. 10. **Run the application:** - From the src/backend directory: ```bash - python app.py + python app_kernel.py ``` - In a new terminal from the src/frontend directory ```bash diff --git a/infra/main.bicep b/infra/main.bicep index ebaab8004..f65eaffad 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -1,6 +1,9 @@ metadata name = 'Multi-Agent Custom Automation Engine' metadata description = 'This module contains the resources required to deploy the Multi-Agent Custom Automation Engine solution accelerator for both Sandbox environments and WAF aligned environments.' +@description('Set to true if you want to deploy WAF-aligned infrastructure.') +param useWafAlignedArchitecture bool + @description('Optional. The prefix to add in the default names given to all deployed Azure resources.') @maxLength(19) param solutionPrefix string = 'macae${uniqueString(deployer().objectId, deployer().tenantId, subscription().subscriptionId, resourceGroup().id)}' @@ -11,7 +14,17 @@ param solutionLocation string = resourceGroup().location @description('Optional. Enable/Disable usage telemetry for module.') param enableTelemetry bool = true +param existingLogAnalyticsWorkspaceId string = '' + // Restricting deployment to only supported Azure OpenAI regions validated with GPT-4o model +@metadata({ + azd : { + type: 'location' + usageName : [ + 'OpenAI.GlobalStandard.gpt-4o, 150' + ] + } +}) @allowed(['australiaeast', 'eastus2', 'francecentral', 'japaneast', 'norwayeast', 'swedencentral', 'uksouth', 'westus']) @description('Azure OpenAI Location') param azureOpenAILocation string @@ -26,6 +39,9 @@ param gptModelVersion string = '2024-08-06' @description('GPT model deployment type:') param modelDeploymentType string = 'GlobalStandard' +@description('Optional. AI model deployment token capacity.') +param gptModelCapacity int = 150 + @description('Set the image tag for the container images used in the solution. Default is "latest".') param imageTag string = 'latest' @@ -46,8 +62,8 @@ param logAnalyticsWorkspaceConfiguration logAnalyticsWorkspaceConfigurationType location: solutionLocation sku: 'PerGB2018' tags: tags - dataRetentionInDays: 365 - existingWorkspaceResourceId: '' + dataRetentionInDays: useWafAlignedArchitecture ? 365 : 30 + existingWorkspaceResourceId: existingLogAnalyticsWorkspaceId } @description('Optional. The configuration to apply for the Multi-Agent Custom Automation Engine Application Insights resource.') @@ -56,7 +72,7 @@ param applicationInsightsConfiguration applicationInsightsConfigurationType = { name: 'appi-${solutionPrefix}' location: solutionLocation tags: tags - retentionInDays: 365 + retentionInDays: useWafAlignedArchitecture ? 365 : 30 } @description('Optional. The configuration to apply for the Multi-Agent Custom Automation Engine Managed Identity resource.') @@ -105,7 +121,7 @@ param networkSecurityGroupAdministrationConfiguration networkSecurityGroupConfig @description('Optional. The configuration to apply for the Multi-Agent Custom Automation Engine virtual network resource.') param virtualNetworkConfiguration virtualNetworkConfigurationType = { - enabled: true + enabled: useWafAlignedArchitecture ? true : false name: 'vnet-${solutionPrefix}' location: solutionLocation tags: tags @@ -131,7 +147,7 @@ param virtualMachineConfiguration virtualMachineConfigurationType = { location: solutionLocation tags: tags adminUsername: 'adminuser' - adminPassword: guid(solutionPrefix, subscription().subscriptionId) + adminPassword: useWafAlignedArchitecture? 'P@ssw0rd1234' : guid(solutionPrefix, subscription().subscriptionId) vmSize: 'Standard_D2s_v3' subnetResourceId: null //Default value set on module configuration } @@ -144,7 +160,7 @@ param aiFoundryAiServicesConfiguration aiServicesConfigurationType = { sku: 'S0' deployments: null //Default value set on module configuration subnetResourceId: null //Default value set on module configuration - modelCapacity: 50 + modelCapacity: gptModelCapacity } @description('Optional. The configuration to apply for the AI Foundry AI Project resource.') @@ -199,8 +215,8 @@ param webServerFarmConfiguration webServerFarmConfigurationType = { enabled: true name: 'asp-${solutionPrefix}' location: solutionLocation - skuName: 'P1v3' - skuCapacity: 3 + skuName: useWafAlignedArchitecture? 'P1v3' : 'B2' + skuCapacity: useWafAlignedArchitecture ? 3 : 1 tags: tags } @@ -729,7 +745,7 @@ var aiFoundryAiServicesModelDeployment = { sku: { name: modelDeploymentType //Curently the capacity is set to 140 for opinanal performance. - capacity: aiFoundryAiServicesConfiguration.?modelCapacity ?? 50 + capacity: aiFoundryAiServicesConfiguration.?modelCapacity ?? gptModelCapacity } raiPolicyName: 'Microsoft.Default' } diff --git a/infra/main.bicepparam b/infra/main.bicepparam deleted file mode 100644 index e0be7c709..000000000 --- a/infra/main.bicepparam +++ /dev/null @@ -1,24 +0,0 @@ -using './main.bicep' - -param solutionPrefix = readEnvironmentVariable('AZURE_ENV_NAME', 'macae') -param solutionLocation = readEnvironmentVariable('AZURE_LOCATION', 'swedencentral') -param azureOpenAILocation = readEnvironmentVariable('AZURE_ENV_OPENAI_LOCATION', 'swedencentral') -param modelDeploymentType = readEnvironmentVariable('AZURE_ENV_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard') -param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o') -param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06') -param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest') -param enableTelemetry = bool(readEnvironmentVariable('AZURE_ENV_ENABLE_TELEMETRY', 'true')) -param logAnalyticsWorkspaceConfiguration = { - dataRetentionInDays: 30 - existingWorkspaceResourceId: '' -} -param applicationInsightsConfiguration = { - retentionInDays: 30 -} -param virtualNetworkConfiguration = { - enabled: false -} -param webServerFarmConfiguration = { - skuCapacity: 1 - skuName: 'B2' -} diff --git a/infra/main.parameters.json b/infra/main.parameters.json index d93f00640..be1b41071 100644 --- a/infra/main.parameters.json +++ b/infra/main.parameters.json @@ -18,12 +18,36 @@ } ] }, - "environmentName": { + "solutionPrefix": { "value": "${AZURE_ENV_NAME}" }, - "location": { + "solutionLocation": { "value": "${AZURE_LOCATION}" }, + "azureOpenAILocation": { + "value": "${AZURE_ENV_OPENAI_LOCATION}" + }, + "modelDeploymentType": { + "value": "${AZURE_ENV_MODEL_DEPLOYMENT_TYPE}" + }, + "gptModelName": { + "value": "${AZURE_ENV_MODEL_NAME}" + }, + "gptModelVersion": { + "value": "${AZURE_ENV_MODEL_VERSION}" + }, + "gptModelCapacity": { + "value": "${AZURE_ENV_MODEL_CAPACITY}" + }, + "imageTag": { + "value": "${AZURE_ENV_IMAGE_TAG}" + }, + "enableTelemetry": { + "value": "${AZURE_ENV_ENABLE_TELEMETRY}" + }, + "existingLogAnalyticsWorkspaceId": { + "value": "${AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID}" + }, "backendExists": { "value": "${SERVICE_BACKEND_RESOURCE_EXISTS=false}" }, diff --git a/infra/main.waf-aligned.bicepparam b/infra/main.waf-aligned.bicepparam deleted file mode 100644 index ac45cdcf3..000000000 --- a/infra/main.waf-aligned.bicepparam +++ /dev/null @@ -1,18 +0,0 @@ -using './main.bicep' - -param solutionPrefix = readEnvironmentVariable('AZURE_ENV_NAME', 'macae') -param solutionLocation = readEnvironmentVariable('AZURE_LOCATION', 'swedencentral') -param azureOpenAILocation = readEnvironmentVariable('AZURE_ENV_OPENAI_LOCATION', 'swedencentral') -param modelDeploymentType = readEnvironmentVariable('AZURE_ENV_MODEL_DEPLOYMENT_TYPE', 'GlobalStandard') -param gptModelName = readEnvironmentVariable('AZURE_ENV_MODEL_NAME', 'gpt-4o') -param gptModelVersion = readEnvironmentVariable('AZURE_ENV_MODEL_VERSION', '2024-08-06') -param imageTag = readEnvironmentVariable('AZURE_ENV_IMAGETAG', 'latest') -param enableTelemetry = bool(readEnvironmentVariable('AZURE_ENV_ENABLE_TELEMETRY', 'true')) -param virtualMachineConfiguration = { - adminUsername: 'adminuser' - adminPassword: 'P@ssw0rd1234' -} - -param logAnalyticsWorkspaceConfiguration = { - existingWorkspaceResourceId: '' -}