|
1 | 1 | #Requires -Version 7.0 |
2 | 2 |
|
3 | 3 | param( |
4 | | - [string]$CosmosDbName, |
5 | | - [string]$DatabaseName, |
6 | | - [string]$ContainerName, |
7 | | - [string]$DirectoryPath, |
8 | | - [string]$ResourceGroup |
| 4 | + [string]$backendUrl, |
| 5 | + [string]$DirectoryPath |
9 | 6 | ) |
10 | 7 |
|
11 | 8 | # Get parameters from azd env, if not provided |
12 | | -if (-not $CosmosDbName) { |
13 | | - $CosmosDbName = $(azd env get-value COSMOSDB_ACCOUNT_NAME) |
14 | | -} |
15 | | -if (-not $DatabaseName) { |
16 | | - $DatabaseName = $(azd env get-value COSMOSDB_DATABASE) |
17 | | -} |
18 | | -if (-not $ContainerName) { |
19 | | - $ContainerName = $(azd env get-value COSMOSDB_CONTAINER) |
| 9 | +if (-not $backendUrl) { |
| 10 | + $backendUrl = $(azd env get-value BACKEND_URL) |
20 | 11 | } |
21 | 12 | if (-not $DirectoryPath) { |
22 | 13 | $DirectoryPath = "data/agent_teams" |
23 | 14 | } |
24 | | -if (-not $ResourceGroup) { |
25 | | - $ResourceGroup = $(azd env get-value AZURE_RESOURCE_GROUP) |
26 | | -} |
| 15 | + |
27 | 16 | $AzSubscriptionId = $(azd env get-value AZURE_SUBSCRIPTION_ID) |
28 | 17 |
|
29 | 18 | # Check if all required arguments are provided |
30 | | -if (-not $CosmosDbName -or -not $DatabaseName -or -not $ContainerName -or -not $DirectoryPath) { |
31 | | - Write-Host "Usage: .\infra\scripts\Upload-Team-Config.ps1 -CosmosDbName <CosmosDbName> -DatabaseName <DatabaseName> -ContainerName <ContainerName> -DirectoryPath <DirectoryPath> [-ResourceGroup <ResourceGroupName>]" |
| 19 | +if (-not $backendUrl -or -not $DirectoryPath) { |
| 20 | + Write-Host "Usage: .\infra\scripts\Upload-Team-Config.ps1 -backendUrl <backendUrl> -DirectoryPath <DirectoryPath>" |
32 | 21 | exit 1 |
33 | 22 | } |
34 | 23 |
|
@@ -95,23 +84,6 @@ if ($currentSubscriptionId -ne $AzSubscriptionId) { |
95 | 84 |
|
96 | 85 | $userPrincipalId = $(az ad signed-in-user show --query id -o tsv) |
97 | 86 |
|
98 | | -$cosmosIsPublicAccessDisabled = $false |
99 | | -if ($ResourceGroup) { |
100 | | - $cosmosPublicAccess = $(az cosmosdb show --name $CosmosDbName --resource-group $ResourceGroup --query "publicNetworkAccess" -o tsv) |
101 | | - if ($cosmosPublicAccess -eq "Disabled") { |
102 | | - $cosmosIsPublicAccessDisabled = $true |
103 | | - Write-Host "Enabling public access for CosmosDB: $CosmosDbName" |
104 | | - az cosmosdb update --name $CosmosDbName --resource-group $ResourceGroup --public-network-access enabled --output none |
105 | | - if ($LASTEXITCODE -ne 0) { |
106 | | - Write-Host "Error: Failed to enable public access for CosmosDB." |
107 | | - exit 1 |
108 | | - } |
109 | | - Write-Host "Public access enabled for CosmosDB: $CosmosDbName" |
110 | | - } else { |
111 | | - Write-Host "Public access is already enabled for CosmosDB: $CosmosDbName" |
112 | | - } |
113 | | -} |
114 | | - |
115 | 87 | # Determine the correct Python command |
116 | 88 | $pythonCmd = $null |
117 | 89 |
|
@@ -173,21 +145,10 @@ Write-Host "Requirements installed" |
173 | 145 |
|
174 | 146 | # Run the Python script to upload team configuration |
175 | 147 | Write-Host "Running the python script to upload team configuration" |
176 | | -$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/team-config-scripts/upload_team_config.py", $CosmosDbName, $DatabaseName, $ContainerName, $DirectoryPath, $userPrincipalId -Wait -NoNewWindow -PassThru |
| 148 | +$process = Start-Process -FilePath $pythonCmd -ArgumentList "infra/scripts/upload_team_config.py", $backendUrl, $DirectoryPath, $userPrincipalId -Wait -NoNewWindow -PassThru |
177 | 149 | if ($process.ExitCode -ne 0) { |
178 | 150 | Write-Host "Error: Team configuration upload failed." |
179 | 151 | exit 1 |
180 | 152 | } |
181 | 153 |
|
182 | | -#disable public access for cosmos |
183 | | -if ($cosmosIsPublicAccessDisabled) { |
184 | | - Write-Host "Disabling public access for CosmosDB: $CosmosDbName" |
185 | | - az cosmosdb update --name $CosmosDbName --resource-group $ResourceGroup --public-network-access disabled --output none |
186 | | - if ($LASTEXITCODE -ne 0) { |
187 | | - Write-Host "Error: Failed to disable public access for CosmosDB." |
188 | | - exit 1 |
189 | | - } |
190 | | - Write-Host "Public access disabled for CosmosDB: $CosmosDbName" |
191 | | -} |
192 | | - |
193 | 154 | Write-Host "Script executed successfully. Team configuration uploaded." |
0 commit comments