Skip to content

Commit 54392ae

Browse files
committed
fixes #97
1 parent 1406732 commit 54392ae

File tree

6 files changed

+61
-5
lines changed

6 files changed

+61
-5
lines changed

app/start-compose.ps1 renamed to deploy/aca/start-compose.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$output = azd -C ..\deploy\aca env get-values
1+
$output = azd env get-values
22

33
foreach ($line in $output) {
44
$name, $value = $line.Split("=")
File renamed without changes.

deploy/aks/start-compose.ps1

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
$output = azd env get-values
2+
3+
foreach ($line in $output) {
4+
$name, $value = $line.Split("=")
5+
$value = $value -replace '^\"|\"$'
6+
[Environment]::SetEnvironmentVariable($name, $value)
7+
}
8+
9+
Write-Host "Environment variables set."
10+
$roles = @(
11+
"5e0bd9bd-7b93-4f28-af87-19fc36ad61bd",
12+
"a97b65f3-24c7-4388-baec-2e87135dc908",
13+
"2a2b9908-6ea1-4ae2-8e65-a410df84e7d1",
14+
"ba92f5b4-2d11-453d-a403-e96b0029c9fe",
15+
"1407120a-92aa-4202-b7e9-c0e197c71c8f",
16+
"8ebe5a00-799e-43f5-93ac-243d3dce84a7",
17+
"7ca78c08-252a-4471-8644-bb5ff32d4ba0",
18+
"4f6d3b9b-027b-4f4c-9142-0e5a2a2247e0"
19+
)
20+
21+
# Check if service principal exists
22+
$servicePrincipal = $(az ad sp list --display-name "azure-ai-chat-java-spi" --query [].appId --output tsv)
23+
24+
if ([string]::IsNullOrEmpty($servicePrincipal)) {
25+
Write-Host "Service principal not found. Creating service principal"
26+
$servicePrincipal = $(az ad sp create-for-rbac --name "azure-ai-chat-java-spi" --role reader --scopes "/subscriptions/$($env:AZURE_SUBSCRIPTION_ID)/resourceGroups/$($env:AZURE_RESOURCE_GROUP)" --query appId --output tsv)
27+
if ($LASTEXITCODE -ne 0) {
28+
Write-Host "Failed to create service principal"
29+
exit $LASTEXITCODE
30+
}
31+
$servicePrincipalObjectId = $(az ad sp show --id $servicePrincipal --query id --output tsv)
32+
Write-Host "Assigning Roles to service principal azure-ai-chat-java-spi with principal id: $servicePrincipal and object id[$servicePrincipalObjectId]"
33+
foreach ($role in $roles) {
34+
Write-Host "Assigning Role[$role] to principal id[$servicePrincipal] for resource[/subscriptions/$($env:AZURE_SUBSCRIPTION_ID)/resourceGroups/$($env:AZURE_RESOURCE_GROUP)]"
35+
az role assignment create `
36+
--role $role `
37+
--assignee-object-id $servicePrincipalObjectId `
38+
--scope "/subscriptions/$($env:AZURE_SUBSCRIPTION_ID)/resourceGroups/$($env:AZURE_RESOURCE_GROUP)" `
39+
--assignee-principal-type ServicePrincipal
40+
}
41+
}
42+
43+
$servicePrincipalPassword = $(az ad sp credential reset --id $servicePrincipal --query password --output tsv)
44+
$servicePrincipalTenant = $(az ad sp show --id $servicePrincipal --query appOwnerOrganizationId --output tsv)
45+
46+
# Set environment variables
47+
[Environment]::SetEnvironmentVariable("servicePrincipal", $servicePrincipal)
48+
[Environment]::SetEnvironmentVariable("servicePrincipalPassword", $servicePrincipalPassword)
49+
[Environment]::SetEnvironmentVariable("servicePrincipalTenant", $servicePrincipalTenant)
50+
51+
52+
Write-Host ""
53+
Write-Host "Starting solution locally using docker compose."
54+
Write-Host ""
55+
56+
docker compose -f ./compose.yaml up
File renamed without changes.

docs/aca/README-ACA.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ azd up
213213
az login
214214
```
215215
216-
2. Change dir to `app`
216+
2. Change dir to `deploy/aca`
217217
218218
```shell
219-
cd app
219+
cd deploy/aca
220220
```
221221
222222
3. Run the `./start-compose.ps1` (Windows) or `./start-compose.sh` (Linux/Mac) scripts or run the "VS Code Task: Start App" to start the project locally.

docs/aks/README-AKS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ azd up
199199
az login
200200
```
201201

202-
2. Change dir to `app`
202+
2. Change dir to `deploy/aks`
203203

204204
```shell
205-
cd app
205+
cd deploy/aks
206206
```
207207

208208
3. Run the `./start-compose.ps1` (Windows) or `./start-compose.sh` (Linux/Mac) scripts or run the "VS Code Task: Start App" to start the project locally.

0 commit comments

Comments
 (0)