Skip to content

Commit 2ce171f

Browse files
author
Seth
committed
Deploy - updated pre-up script with UX for prompting pre-existing project conns
1 parent e4b53c3 commit 2ce171f

3 files changed

Lines changed: 50 additions & 17 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ The diagram below illustrates the capabilities included in the template.
3737

3838
- Provides the ability to [add additional Azure services during deployment](docs/add_additional_services.md), configured to connect via isolation to enrich your AI project.
3939
(API Management, CosmosDB, Azure SQL DB)
40+
41+
- Offers ability to start with an existing Azure AI Project which will provision dependant Azure resources based on the Project's established connections within AI Foundry.
4042

4143
## Prerequisites and high-level steps
4244

azure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ hooks:
88
windows:
99
shell: pwsh
1010
run: ./scripts/SetConnectionsEnvironmentVariables.ps1
11-
interactive: false
11+
interactive: true
1212
continueOnError: false

scripts/SetConnectionsEnvironmentVariables.ps1

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,66 @@ param (
1515
[switch]$includeVerboseResponseOutputs
1616
)
1717

18-
if (-not $tenant) {
18+
if (-not $tenant -and $env:AZURE_ORIGINAL_TENANT_ID) {
1919
$tenant = $env:AZURE_ORIGINAL_TENANT_ID
20-
Write-Output "Tenant parameter not provided. Using environment variable AZURE_ORIGINAL_TENANT_ID: $tenant"
20+
if ($includeVerboseResponseOutputs) {
21+
Write-Output "Tenant parameter not provided. Using environment variable AZURE_ORIGINAL_TENANT_ID: $tenant"
22+
}
2123
}
2224

23-
if (-not $subscription) {
25+
if (-not $subscription -and $env:AZURE_ORIGINAL_SUBSCRIPTION_ID) {
2426
$subscription = $env:AZURE_ORIGINAL_SUBSCRIPTION_ID
25-
Write-Output "Subscription parameter not provided. Using environment variable AZURE_ORIGINAL_SUBSCRIPTION_ID: $subscription"
27+
if ($includeVerboseResponseOutputs) {
28+
Write-Output "Subscription parameter not provided. Using environment variable AZURE_ORIGINAL_SUBSCRIPTION_ID: $subscription"
29+
}
2630
}
2731

28-
if (-not $resourceGroup) {
32+
if (-not $resourceGroup -and $env:AZURE_ORIGINAL_RESOURCE_GROUP) {
2933
$resourceGroup = $env:AZURE_ORIGINAL_RESOURCE_GROUP
30-
Write-Output "ResourceGroup parameter not provided. Using environment variable AZURE_ORIGINAL_RESOURCE_GROUP: $resourceGroup"
34+
if ($includeVerboseResponseOutputs) {
35+
Write-Output "ResourceGroup parameter not provided. Using environment variable AZURE_ORIGINAL_RESOURCE_GROUP: $resourceGroup"
36+
}
3137
}
3238

33-
if (-not $workspace) {
39+
if (-not $workspace -and $env:AZURE_ORIGINAL_WORKSPACE_NAME) {
3440
$workspace = $env:AZURE_ORIGINAL_WORKSPACE_NAME
35-
Write-Output "Workspace parameter not provided. Using environment variable AZURE_ORIGINAL_WORKSPACE_NAME: $workspace"
41+
if ($includeVerboseResponseOutputs) {
42+
Write-Output "Workspace (Project) parameter not provided. Using environment variable AZURE_ORIGINAL_WORKSPACE_NAME: $workspace"
43+
}
3644
}
3745

3846
if (-not $tenant -or -not $subscription -or -not $resourceGroup -or -not $workspace) {
39-
Write-Output "One or more required parameters are missing. Exiting script."
40-
return
47+
$response = Read-Host "Start with existing Project connections? [NOTE: This action cannot be undone after executing. To revert, create a new AZD environment and run the process again.] (yes/no)"
48+
if ($response -eq "yes") {
49+
if (-not $tenant) {
50+
$tenant = Read-Host "Enter Tenant ID"
51+
}
52+
53+
if (-not $subscription) {
54+
$subscription = Read-Host "Enter Subscription ID"
55+
}
56+
57+
if (-not $resourceGroup) {
58+
$resourceGroup = Read-Host "Enter Resource Group"
59+
}
60+
61+
if (-not $workspace) {
62+
$workspace = Read-Host "Enter Workspace / Project Name"
63+
}
64+
65+
} elseif ($response -eq "no") {
66+
Write-Output "Not starting with existing Project. Exiting script."
67+
return
68+
} else {
69+
Write-Output "Invalid response. Exiting script."
70+
return
71+
}
72+
} else {
73+
Write-Output "All parameters provided. Starting with existing Project ${workspace}."
74+
}
75+
76+
if (-not $tenant -or -not $subscription -or -not $resourceGroup -or -not $workspace) {
77+
throw "Unable to start with existing Project: One or more required parameters are missing."
4178
}
4279

4380
if (-not (Get-AzContext)) {
@@ -151,12 +188,6 @@ foreach ($connection in $connections) {
151188
}
152189
}
153190

154-
if ($category -eq "ApiKey" -and $target -eq "https://api.bing.microsoft.com/") {
155-
$env:AZURE_AI_BING_GROUNDING_ENABLED = "true"
156-
azd env set 'AZURE_AI_SPEECH_ENABLED' 'true'
157-
Write-Output "Environment variable AZURE_AI_BING_GROUNDING_ENABLED set to true"
158-
}
159-
160191
Write-Output "-------------------------"
161192
}
162193
Write-Output "----------------------------------"

0 commit comments

Comments
 (0)