File tree 3 files changed +28
-9
lines changed
src/Common/Commands.Common/Common
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
119
119
}
120
120
}
121
121
122
- private void UpdateSubscriptionRegisteredProviders ( AzureSubscription subscription , List < string > providers )
122
+ private void UpdateSubscriptionRegisteredProviders ( AzureSubscription subscription , List < string > providers )
123
123
{
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
+ }
132
140
}
133
141
}
134
142
}
Original file line number Diff line number Diff line change @@ -41,4 +41,14 @@ function Test-UpdateStorageAccount
41
41
Set-AzureSubscription - SubscriptionName $subscription - CurrentStorageAccountName $accounts [1 ].StorageAccountName
42
42
$storageAccountName = $ (Get-AzureStorageContainer )[0 ].Context.StorageAccountName
43
43
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
44
54
}
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ Run-TestProtected { Test-UpdateStorageAccount } "Test-UpdateStorageAccount"
107
107
$serviceCommands | % { Run- TestProtected $_ $_.ToString () }
108
108
Write-Host - ForegroundColor Green " STARTING RESOURCE MANAGER TESTS"
109
109
Switch-AzureMode AzureResourceManager > $null
110
+ Run- TestProtected { Test-GetBatchAccountWithSubscriptionDataFile $credential } " Test-GetBatchAccountWithSubscriptionDataFile"
110
111
$resourceCommands | % { Run- TestProtected $_ $_.ToString () }
111
112
Write-Host
112
113
Write-Host - ForegroundColor Green " $global :passedCount / $global :totalCount Installation Tests Pass"
You can’t perform that action at this time.
0 commit comments