File tree Expand file tree Collapse file tree 3 files changed +28
-9
lines changed
src/Common/Commands.Common/Common Expand file tree Collapse file tree 3 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -119,16 +119,24 @@ private void RegisterServiceManagementProviders<T>(AzureContext context) where T
119119 }
120120 }
121121
122- private void UpdateSubscriptionRegisteredProviders ( AzureSubscription subscription , List < string > providers )
122+ private void UpdateSubscriptionRegisteredProviders ( AzureSubscription subscription , List < string > providers )
123123 {
124- if ( providers != null && providers . Count > 0 )
125- {
126- subscription . SetOrAppendProperty ( AzureSubscription . Property . RegisteredResourceProviders ,
127- providers . ToArray ( ) ) ;
128- ProfileClient profileClient = new ProfileClient ( ) ;
129- profileClient . AddOrSetSubscription ( subscription ) ;
130- profileClient . Profile . Save ( ) ;
131- }
124+ if ( providers != null && providers . Count > 0 )
125+ {
126+ subscription . SetOrAppendProperty ( AzureSubscription . Property . RegisteredResourceProviders ,
127+ providers . ToArray ( ) ) ;
128+ try
129+ {
130+ ProfileClient profileClient = new ProfileClient ( ) ;
131+ profileClient . AddOrSetSubscription ( subscription ) ;
132+ profileClient . Profile . Save ( ) ;
133+ }
134+ catch ( KeyNotFoundException )
135+ {
136+ // if using a subscription data file, do not write registration to disk
137+ // long term solution is using -Profile parameter
138+ }
139+ }
132140 }
133141 }
134142}
Original file line number Diff line number Diff line change @@ -41,4 +41,14 @@ function Test-UpdateStorageAccount
4141 Set-AzureSubscription - SubscriptionName $subscription - CurrentStorageAccountName $accounts [1 ].StorageAccountName
4242 $storageAccountName = $ (Get-AzureStorageContainer )[0 ].Context.StorageAccountName
4343 Assert-AreEqual $storageAccountName $accounts [1 ].StorageAccountName
44+ }
45+
46+ function Test-GetBatchAccountWithSubscriptionDataFile
47+ {
48+ param ([PSCredential ] $credential )
49+ Get-AzureSubscription | Remove-AzureSubscription - Force
50+ $account = Add-AzureAccount - Credential $credential - SubscriptionDataFile " File.txt"
51+ Select-AzureSubscription - SubscriptionId $account.Subscriptions.Split (" `r`n " )[0 ] - SubscriptionDataFile " File.txt"
52+ Get-AzureBatchAccount
53+ Add-AzureAccount - Credential $credential
4454}
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ Run-TestProtected { Test-UpdateStorageAccount } "Test-UpdateStorageAccount"
107107$serviceCommands | % { Run- TestProtected $_ $_.ToString () }
108108Write-Host - ForegroundColor Green " STARTING RESOURCE MANAGER TESTS"
109109Switch-AzureMode AzureResourceManager > $null
110+ Run- TestProtected { Test-GetBatchAccountWithSubscriptionDataFile $credential } " Test-GetBatchAccountWithSubscriptionDataFile"
110111$resourceCommands | % { Run- TestProtected $_ $_.ToString () }
111112Write-Host
112113Write-Host - ForegroundColor Green " $global :passedCount / $global :totalCount Installation Tests Pass"
You can’t perform that action at this time.
0 commit comments