-
Notifications
You must be signed in to change notification settings - Fork 2
/
Create-ClientSecrets.ps1
34 lines (28 loc) · 1.36 KB
/
Create-ClientSecrets.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
param(
[Parameter()][string]$SettingsFile = 'developer-settings.json',
[Parameter(Mandatory)][string]$EnvironmentName
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
Write-Host "Reading settings from file $SettingsFile"
$settingsJson = Get-Content -Raw -Path $SettingsFile | ConvertFrom-Json
$context = Get-AzContext
$busKey = Get-AzServiceBusKey -ResourceGroupName $EnvironmentName -Namespace $EnvironmentName -Name 'RootManageSharedAccessKey'
$output = @{
ConnectionString = $busKey.PrimaryConnectionString
AzureResourceGroup = $EnvironmentName
AzureSubscriptionId = $context.Subscription.Id
AzureSpAppId = $settingsJson.ServicePrincipal.AppId
AzureSpPassword = $settingsJson.ServicePrincipal.Password
AzureSpTenantId = $context.Tenant.Id
AzureNamespace = $EnvironmentName
AzureRetryMinimumBackoff = 5
AzureRetryMaximumBackoff = 10
AzureMaximumRetryCount = 10
}
$filename = "client-secrets.json"
$projectLocation = "Protacon.RxMq.AzureServiceBus.Tests"
$legacyProjectLocation = "Protacon.RxMq.AzureServiceBusLegacy.Tests"
$output | ConvertTo-Json -depth 100 | Out-File "$projectLocation\$filename"
Copy-Item "$projectLocation\$filename" -Destination $legacyProjectLocation
Write-Host "Write file '$filename' to '$projectLocation', '$legacyProjectLocation'"