diff --git a/docs/DeploymentGuide.md b/docs/DeploymentGuide.md index a0140e7b..c2ec876d 100644 --- a/docs/DeploymentGuide.md +++ b/docs/DeploymentGuide.md @@ -124,6 +124,7 @@ When you start the deployment, most parameters will have **default values**, but | **Use Local Build** | Boolean flag to determine if local container builds should be used. | false | | **Image Tag** | Image version for deployment (allowed values: `latest`, `dev`, `hotfix`). | latest | | **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(none)* | +| **Existing Azure AI Foundry Project** | To reuse an existing Azure AI Foundry Project ID instead of creating a new one. | *(none)* | @@ -148,6 +149,14 @@ To adjust quota settings, follow these [steps](./AzureGPTQuotaSettings.md). +
+ + Reusing an Existing Azure AI Foundry Project + + Guide to get your [Existing Project ID](/docs/re-use-foundry-project.md) + +
+ ### Deploying with AZD Once you've opened the project in [Codespaces](#github-codespaces), [Dev Containers](#vs-code-dev-containers), or [locally](#local-environment), you can deploy it to Azure by following these steps: diff --git a/docs/images/re_use_foundry_project/azure_ai_foundry_list.png b/docs/images/re_use_foundry_project/azure_ai_foundry_list.png new file mode 100644 index 00000000..784bc85c Binary files /dev/null and b/docs/images/re_use_foundry_project/azure_ai_foundry_list.png differ diff --git a/docs/images/re_use_foundry_project/navigate_to_projects.png b/docs/images/re_use_foundry_project/navigate_to_projects.png new file mode 100644 index 00000000..11082c15 Binary files /dev/null and b/docs/images/re_use_foundry_project/navigate_to_projects.png differ diff --git a/docs/images/re_use_foundry_project/project_resource_id.png b/docs/images/re_use_foundry_project/project_resource_id.png new file mode 100644 index 00000000..7835ea9d Binary files /dev/null and b/docs/images/re_use_foundry_project/project_resource_id.png differ diff --git a/docs/re-use-foundry-project.md b/docs/re-use-foundry-project.md new file mode 100644 index 00000000..a0f9a06f --- /dev/null +++ b/docs/re-use-foundry-project.md @@ -0,0 +1,44 @@ +[← Back to *DEPLOYMENT* guide](/docs/DeploymentGuide.md#deployment-options--steps) + +# Reusing an Existing Azure AI Foundry Project +To configure your environment to use an existing Azure AI Foundry Project, follow these steps: +--- +### 1. Go to Azure Portal +Go to https://portal.azure.com + +### 2. Search for Azure AI Foundry +In the search bar at the top, type "Azure AI Foundry" and click on it. Then select the Foundry service instance where your project exists. + +![alt text](../docs/images/re_use_foundry_project/azure_ai_foundry_list.png) + +### 3. Navigate to Projects under Resource Management +On the left sidebar of the Foundry service blade: + +- Expand the Resource Management section +- Click on Projects (this refers to the active Foundry project tied to the service) + +### 4. Click on the Project +From the Projects view: Click on the project name to open its details + + Note: You will see only one project listed here, as each Foundry service maps to a single project in this accelerator + +![alt text](../docs/images/re_use_foundry_project/navigate_to_projects.png) + +### 5. Copy Resource ID +In the left-hand menu of the project blade: + +- Click on Properties under Resource Management +- Locate the Resource ID field +- Click on the copy icon next to the Resource ID value + +![alt text](../docs/images/re_use_foundry_project/project_resource_id.png) + +### 6. Set the Foundry Project Resource ID in Your Environment +Run the following command in your terminal +```bash +azd env set AZURE_ENV_FOUNDRY_PROJECT_ID '' +``` +Replace `` with the value obtained from Step 5. + +### 7. Continue Deployment +Proceed with the next steps in the [deployment guide](/docs/DeploymentGuide.md#deployment-options--steps). diff --git a/infra/modules/account/main.bicep b/infra/modules/account/main.bicep index de41138c..2bcfbd48 100644 --- a/infra/modules/account/main.bicep +++ b/infra/modules/account/main.bicep @@ -277,7 +277,7 @@ module existing_cognitive_service_dependencies './modules/dependencies.bicep' = projectName: projectName projectDescription: projectDescription azureExistingAIProjectResourceId: existingFoundryProjectResourceId - location: location + location: cognitiveServiceExisting.?location! deployments: deployments diagnosticSettings: diagnosticSettings lock: lock diff --git a/infra/modules/account/modules/dependencies.bicep b/infra/modules/account/modules/dependencies.bicep index c2d7de6f..9aea2dc5 100644 --- a/infra/modules/account/modules/dependencies.bicep +++ b/infra/modules/account/modules/dependencies.bicep @@ -23,8 +23,8 @@ param name string ]) param sku string = 'S0' -@description('Optional. Location for all Resources.') -param location string = resourceGroup().location +@description('Optional. Location for Cognitive Services.') +param location string @description('Optional. Tags of the resource.') param tags object? diff --git a/infra/modules/account/modules/project.bicep b/infra/modules/account/modules/project.bicep index 0e1a6c6f..82520437 100644 --- a/infra/modules/account/modules/project.bicep +++ b/infra/modules/account/modules/project.bicep @@ -2,7 +2,7 @@ param name string @description('Required. The location of the Project resource.') -param location string = resourceGroup().location +param location string @description('Optional. The description of the AI Foundry project to create. Defaults to the project name.') param desc string = name @@ -19,7 +19,7 @@ param azureExistingAIProjectResourceId string = '' // // Extract components from existing AI Project Resource ID if provided var useExistingProject = !empty(azureExistingAIProjectResourceId) var existingProjName = useExistingProject ? last(split(azureExistingAIProjectResourceId, '/')) : '' -var existingProjEndpoint = useExistingProject ? format('https://{0}.services.ai.azure.com/api/projects/{1}', aiServicesName, existingProjName) : '' +// var existingProjEndpoint = useExistingProject ? format('https://{0}.services.ai.azure.com/api/projects/{1}', aiServicesName, existingProjName) : '' // Reference to cognitive service in current resource group for new projects resource cogServiceReference 'Microsoft.CognitiveServices/accounts@2024-10-01' existing = { @@ -41,11 +41,19 @@ resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-pre } } +// Assign identity to existing project +resource existingProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = if (useExistingProject && !empty(existingProjName)) { + name: existingProjName + parent: cogServiceReference + location: location + identity: { type: 'SystemAssigned' } +} + @description('AI Project metadata including name, resource ID, and API endpoint.') output aiProjectInfo aiProjectOutputType = { - name: useExistingProject ? existingProjName : aiProject.name - resourceId: useExistingProject ? azureExistingAIProjectResourceId : aiProject.id - apiEndpoint: useExistingProject ? existingProjEndpoint : aiProject.properties.endpoints['AI Foundry API'] + name: useExistingProject ? existingProject.name : aiProject.name + resourceId: useExistingProject ? existingProject.id : aiProject.id + apiEndpoint: useExistingProject ? existingProject.properties.endpoints['AI Foundry API'] : aiProject.properties.endpoints['AI Foundry API'] } @export()