Skip to content

feat: Implemented Reusing Log analytics workspace #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged
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
4 changes: 4 additions & 0 deletions docs/CustomizingAzdParameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ Change the Model Capacity (choose a number based on available GPT model capacity
azd env set AZURE_ENV_MODEL_CAPACITY 30
```

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 '<Existing Log Analytics Workspace Id>'
```
1 change: 1 addition & 0 deletions docs/DeploymentGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ When you start the deployment, most parameters will have **default values**, but
| **Resource Prefix** | Prefix for all resources created by this template. This prefix will be used to create unique names for all resources. The prefix must be unique within the resource group. | None |
| **AI Location** | Location for all AI services resources. This location can be different from the resource group location | None |
| **Capacity** | Configure capacity for **gpt-4o**. | 5k |
| **Existing Log analytics workspace** | To reuse the existing Log analytics workspace Id. | |

This accelerator can be configured to use authentication.

Expand Down
16 changes: 14 additions & 2 deletions infra/deploy_ai_foundry.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ param managedIdentityObjectId string
param aiServicesEndpoint string
param aiServicesKey string
param aiServicesId string

param existingLogAnalyticsWorkspaceId string = ''

var useExisting = !empty(existingLogAnalyticsWorkspaceId)
var existingLawResourceGroup = useExisting ? split(existingLogAnalyticsWorkspaceId, '/')[4] : ''
var existingLawName = useExisting ? split(existingLogAnalyticsWorkspaceId, '/')[8] : ''

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

var storageName = '${abbrs.storage.storageAccount}${solutionName}'
Expand All @@ -32,7 +39,12 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVaultName
}

resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
resource existingLogAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' existing = if (useExisting) {
name: existingLawName
scope: resourceGroup(existingLawResourceGroup)
}

resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = if (!useExisting) {
name: workspaceName
location: location
tags: {}
Expand Down Expand Up @@ -303,7 +315,7 @@ output aiProjectName string = aiHubProject.name

output storageAccountName string = storageNameCleaned

output logAnalyticsId string = logAnalytics.id
output logAnalyticsId string = useExisting ? existingLogAnalyticsWorkspace.id : logAnalytics.id
output storageAccountId string = storage.id

output projectConnectionString string = '${split(aiHubProject.properties.discoveryUrl, '/')[2]};${subscription().subscriptionId};${resourceGroup().name};${aiHubProject.name}'
3 changes: 3 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var safePrefix = length(Prefix) > 20 ? substring(Prefix, 0, 20) : Prefix
param AzureAiServiceLocation string // The location used for all deployed resources. This location must be in the same region as the resource group.
param capacity int = 5

param existingLogAnalyticsWorkspaceId string = ''

var uniqueId = toLower(uniqueString(subscription().id, safePrefix, resourceGroup().location))
var UniquePrefix = 'cm${padLeft(take(uniqueId, 12), 12, '0')}'
var ResourcePrefix = take('cm${safePrefix}${UniquePrefix}', 15)
Expand Down Expand Up @@ -136,6 +138,7 @@ module azureAifoundry 'deploy_ai_foundry.bicep' = {
aiServicesEndpoint: azureAiServices.properties.endpoint
aiServicesKey: azureAiServices.listKeys().key1
aiServicesId: azureAiServices.id
existingLogAnalyticsWorkspaceId: existingLogAnalyticsWorkspaceId
}
scope: resourceGroup(resourceGroup().name)
}
Expand Down
1 change: 1 addition & 0 deletions infra/main.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ using './main.bicep'

param AzureAiServiceLocation = readEnvironmentVariable('AZURE_LOCATION','japaneast')
param Prefix = readEnvironmentVariable('AZURE_ENV_NAME','azdtemp')
param existingLogAnalyticsWorkspaceId = readEnvironmentVariable('AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID', '')