Skip to content

Commit d3079d6

Browse files
committed
use secure string for Azure subscription owner password, expose switch for enableSyndication
1 parent 7e194d7 commit d3079d6

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

Registration/RegisterWithAzure.ps1

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# Copyright (c) Microsoft Corporation. All rights reserved.
2-
# See LICENSE.txt in the project root for license information.
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# See LICENSE.txt in the project root for license information.
33

4-
<#
5-
6-
.SYNOPSIS
7-
8-
This script can be used to register Azure Stack POC with Azure. To run this script, you must have a public Azure subscription of any type.
9-
There must also be an account that is an owner or contributor of the subscription. This account cannot be an MSA (i.e. cannot be live.com or hotmail.com) or 2FA account.
4+
<#
105
11-
.DESCRIPTION
12-
13-
RegisterToAzure runs local scripts to connect your Azure Stack to Azure. After connecting with Azure, you can test marketplace syndication.
6+
.SYNOPSIS
7+
8+
This script can be used to register Azure Stack POC with Azure. To run this script, you must have a public Azure subscription of any type.
9+
There must also be an account that is an owner or contributor of the subscription. This account cannot be an MSA (i.e. cannot be live.com or hotmail.com) or 2FA account.
10+
11+
.DESCRIPTION
12+
13+
RegisterToAzure runs local scripts to connect your Azure Stack to Azure. After connecting with Azure, you can test marketplace syndication.
1414
1515
The script will follow four steps:
1616
Configure bridge identity: configures Azure Stack so that it can call to Azure via your Azure subscription
1717
Get registration request: get Azure Stack environment information to create a registration for this azure stack in azure
1818
Register with Azure: uses Azure powershell to create an "Azure Stack Registration" resource on your Azure subscription
1919
Activate Azure Stack: final step in connecting Azure Stack to be able to call out to Azure
2020
21-
.PARAMETER azureSubscriptionId
22-
21+
.PARAMETER azureSubscriptionId
22+
2323
2424
Azure subscription ID that you want to register your Azure Stack with. This parameter is mandatory.
2525
26-
.PARAMETER azureDirectoryTenantName
27-
26+
.PARAMETER azureDirectoryTenantName
27+
2828
Name of your AAD Tenant which your Azure subscription is a part of. This parameter is mandatory.
2929
3030
.PARAMETER azureAccountId
31-
31+
3232
Username for an owner/contributor of the azure subscription. This user must not be an MSA or 2FA account. This parameter is mandatory.
3333
3434
.PARAMETER azureCredentialPassword
@@ -45,19 +45,19 @@ URI used for ActivateBridge.ps1 that refers to the endpoint for Azure Resource M
4545
4646
.EXAMPLE
4747
48-
This script must be run from the Host machine of the POC.
48+
This script must be run from the Host machine of the POC.
4949
.\RegisterWithAzure.ps1 -azureSubscriptionId "5e0ae55d-0b7a-47a3-afbc-8b372650abd3" -azureDirectoryTenantId "contoso.onmicrosoft.com" -azureAccountId "serviceadmin@contoso.onmicrosoft.com" -azureCredentialPassword "password"
5050
51-
52-
.NOTES
53-
Ensure that you have an Azure subscription
51+
52+
.NOTES
53+
Ensure that you have an Azure subscription
5454
#>
5555

5656
[CmdletBinding()]
5757
param(
5858

5959
[Parameter(Mandatory=$true)]
60-
[String] $azureCredentialPassword,
60+
[SecureString] $azureCredentialPassword,
6161

6262
[Parameter(Mandatory=$true)]
6363
[String] $azureAccountId,
@@ -73,8 +73,11 @@ param(
7373

7474
[Parameter(Mandatory=$false)]
7575
[String] $azureResourceManagerEndpoint = "https://management.azure.com",
76-
77-
[Parameter(Manadatory=$false)]
76+
77+
[Parameter(Mandatory=$false)]
78+
[Switch] $enableSyndication = $true,
79+
80+
[Parameter(Mandatory=$false)]
7881
[Switch] $reportUsage = $false
7982
)
8083

@@ -87,18 +90,19 @@ param(
8790
# Uses refresh tokens and supports 2fa, MSA accounts
8891
#
8992

90-
#$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
91-
#$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
93+
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
94+
$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
9295

9396
Import-Module C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1 -Force
94-
cd C:\CloudDeployment\Setup\Activation\Bridge
97+
Set-Location C:\CloudDeployment\Setup\Activation\Bridge
9598

9699
#
97100
# Pre-req: Obtain refresh token for Azure identity
98101
#
99102
Import-Module C:\CloudDeployment\Setup\Common\AzureADConfiguration.psm1 -ErrorAction Stop
100103

101-
$AzureCredential = New-Object System.Management.Automation.PSCredential($azureAccountId, (ConvertTo-SecureString -String $azureCredentialPassword -AsPlainText -Force))
104+
$AzureCredential = New-Object System.Management.Automation.PSCredential($azureAccountId, $azureCredentialPassword)
105+
102106
$AzureDirectoryTenantId = Get-TenantIdFromName -azureEnvironment $azureEnvironment -tenantName $azureDirectoryTenantName
103107

104108
if($AzureCredential)
@@ -147,11 +151,11 @@ Write-Verbose "Register Azure Stack with Azure completed"
147151

148152
$activationDataFile = "c:\temp\regOutput2.json"
149153
$reg = Get-Content $registrationOutputFile | ConvertFrom-Json
150-
$enablesyndication = $true
154+
151155
$newProps = @{
152156
ObjectId = $reg.properties.ObjectId
153157
ProvisioningState = $reg.properties.provisioningState
154-
enablesyndication = $enablesyndication
158+
enablesyndication = $enableSyndication
155159
reportusage = $reportUsage
156160
}
157161

0 commit comments

Comments
 (0)