Skip to content

Commit 6e05a93

Browse files
Harald S. FianbakkenHarald S. Fianbakken
authored andcommitted
Fixed CLI to use static cloudConfig generation - avoiding chicken and egg problem
1 parent e98997d commit 6e05a93

File tree

2 files changed

+30
-47
lines changed

2 files changed

+30
-47
lines changed

azure-local/manage/disconnected-operations-cli.md

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -123,56 +123,39 @@ To set up Azure CLI for disconnected operations on Azure Local, follow these ste
123123
```PowerShell
124124
function Get-ApplianceAzCliCloudConfig
125125
{
126-
[CmdletBinding()]
127-
[OutputType([String])]
128-
param (
129-
[Parameter(Position = 0, Mandatory = $true)]
130-
[string]
131-
$ArmEndpoint,
126+
[CmdletBinding()]
127+
[OutputType([String])]
128+
param (
129+
[Parameter(Position = 0, Mandatory = $true)]
130+
[string]
131+
$fqdn,
132+
[Parameter(Position = 1, Mandatory = $false)]
133+
[string]
134+
$exportToFile
135+
)
132136
133-
[Parameter(Position = 1, Mandatory = $false)]
134-
[string]
135-
$OutputFolder,
136-
137-
[Parameter(Position = 2, Mandatory = $false)]
138-
[string]
139-
$ApiVersion = "2022-09-01" )
140-
141-
$armMetadataUrl = "$($ArmEndpoint.TrimEnd('/'))/metadata/endpoints?api-version=${ApiVersion}"
142-
try
137+
$cloudConfig = @"
143138
{
144-
$response = Invoke-WebRequest $armMetadataUrl `
145-
-Method 'GET' `
146-
-ContentType "application/json" `
147-
-UseBasicParsing
148-
}
149-
catch
150-
{
151-
Write-Error "Failed to get ARM metadata endpoints at '$armMetadataUrl'."
152-
throw $_
153-
}
154-
155-
$cloudEndpoints = $response.Content | ConvertFrom-Json
156-
$cloudConfig = @{
157-
endpoints = @{
158-
activeDirectory = "$($cloudEndpoints.authentication.loginEndpoint.TrimEnd('/'))/adfs"
159-
activeDirectoryGraphResourceId = $cloudEndpoints.graph
160-
activeDirectoryResourceId = $cloudEndpoints.authentication.audiences[0]
161-
resourceManager = $cloudEndpoints.resourceManager
162-
microsoftGraphResourceId = $cloudEndpoints.graph
163-
}
164-
suffixes = @{
165-
storageEndpoint = $cloudEndpoints.suffixes.storage
166-
keyvaultDns = $cloudEndpoints.suffixes.keyvaultDns
167-
acrLoginServerEndpoint = $cloudEndpoints.suffixes.acrLoginServer
168-
}
139+
"suffixes": {
140+
"keyvaultDns": ".vault.autonomous.cloud.private",
141+
"storageEndpoint": "autonomous.cloud.private",
142+
"acrLoginServerEndpoint": ".edgeacr.autonomous.cloud.private"
143+
},
144+
"endpoints": {
145+
"activeDirectory": "https://login.autonomous.cloud.private/adfs",
146+
"activeDirectoryGraphResourceId": "https://graph.autonomous.cloud.private",
147+
"resourceManager": "https://armmanagement.autonomous.cloud.private",
148+
"microsoftGraphResourceId": "https://graph.autonomous.cloud.private",
149+
"activeDirectoryResourceId": "https://armmanagement.autonomous.cloud.private"
150+
}
169151
}
170-
$cloudConfigJson = $cloudConfig | ConvertTo-Json
171-
if ($OutputFolder)
152+
"@ -replace "autonomous.cloud.private", $fqdn
153+
154+
if ($exportToFile)
172155
{
173-
$cloudConfigJson | Set-Content -Path "$OutputFolder\cloudconfig.json"
156+
$cloudConfig | Set-Content -Path "$exportToFile"
174157
}
175-
return $cloudConfigJson
158+
return $cloudConfig
176159
}
177160
```
178161
@@ -182,7 +165,7 @@ To set up Azure CLI for disconnected operations on Azure Local, follow these ste
182165
az config set core.enable_broker_on_windows=false
183166
az config set core.instance_discovery=false
184167
$fqdn = "autonomous.cloud.private"
185-
$cloudConfigJson = Get-ApplianceAzCliCloudConfig -ArmEndpoint "https://armmanagement.$($fqdn)/"
168+
$cloudConfigJson = Get-ApplianceAzCliCloudConfig -fqdn $fqdn
186169
187170
# Write the content to a file cloudConfig.json
188171
$cloudConfigJson | Out-File -FilePath cloudConfig.json

azure-local/manage/disconnected-operations-pki.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ _continue_ = "DNS=$subject"
294294
You need the root certificate public key for deployment. The following example shows how to export your root certificate public key:
295295

296296
```azurecli
297-
certutil -ca.cert applianceRoot.cer
297+
certutil -ca.cert C:\AzureLocalDisconnectedOperations\applianceRoot.cer
298298
```
299299

300300
For more information, see [Active Directory Certificate Services](/troubleshoot/windows-server/certificates-and-public-key-infrastructure-pki/export-root-certification-authority-certificate).

0 commit comments

Comments
 (0)