@@ -36,10 +36,6 @@ export class AzurePickers extends Disposable {
36
36
super ( ) ;
37
37
}
38
38
39
- public async getFilteredSubscriptions ( ) : Promise < AzureSubscription [ ] > {
40
- return await this . vsCodeAzureSubscriptionProvider . getSubscriptions ( true ) ;
41
- }
42
-
43
39
public async getAllSubscriptions ( ) : Promise < AzureSubscription [ ] > {
44
40
return await this . vsCodeAzureSubscriptionProvider . getSubscriptions ( false ) ;
45
41
}
@@ -144,11 +140,26 @@ export class AzurePickers extends Disposable {
144
140
public async pickSubscription ( context : IActionContext ) : Promise < AzureSubscription > {
145
141
await this . EnsureSignedIn ( ) ;
146
142
147
- const subscriptions = await this . vsCodeAzureSubscriptionProvider . getSubscriptions ( ) ;
143
+ const subscriptions = await this . getAllSubscriptions ( ) ;
148
144
if ( subscriptions . length === 0 ) {
149
- throw new Error ( "No subscriptions found" ) ;
145
+ let message = "No subscriptions found." ;
146
+ try {
147
+ const tenants = await this . vsCodeAzureSubscriptionProvider . getTenants ( ) ;
148
+ const signInStatusPromises = tenants . map ( async ( tenant ) => {
149
+ const isSignedIn = await this . vsCodeAzureSubscriptionProvider . isSignedIn ( tenant . tenantId ) ;
150
+ return `${ tenant . tenantId } (${ isSignedIn ? 'signed in' : 'signed out' } )` ;
151
+ } ) ;
152
+ const signInStatus = await Promise . all ( signInStatusPromises ) ;
153
+ message += ` Available tenants: ${ signInStatus . join ( ", " ) } ` ;
154
+ } catch ( err ) {
155
+ this . outputChannelManager . appendToOutputChannel ( parseError ( err ) . message ) ;
156
+ }
157
+
158
+ throw new Error ( message ) ;
150
159
}
151
160
161
+ subscriptions . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
162
+
152
163
const picks = subscriptions . map ( s => {
153
164
return < IAzureQuickPickItem < AzureSubscription > > {
154
165
label : s . name ,
@@ -167,6 +178,8 @@ export class AzurePickers extends Disposable {
167
178
const client : ResourceManagementClient = await createResourceManagementClient ( [ context , subscriptionContext ] ) ;
168
179
const rgs : ResourceGroup [ ] = await uiUtils . listAllIterator ( client . resourceGroups . list ( ) ) ;
169
180
181
+ rgs . sort ( ( a , b ) => nonNullProp ( a , "name" ) . localeCompare ( nonNullProp ( b , "name" ) ) ) ;
182
+
170
183
const createNewRGItem : IAzureQuickPickItem < ResourceGroup | undefined > = {
171
184
label : '$(plus) Create new resource group' ,
172
185
data : undefined ,
@@ -190,7 +203,7 @@ export class AzurePickers extends Disposable {
190
203
191
204
const selected = await context . ui . showQuickPick ( picks , { placeHolder : "Select resource group" } ) ;
192
205
if ( selected === createNewRGItem ) {
193
- return await this . promptAndCreateResourceGroup ( context , subscription ) ;
206
+ return await this . promptCreateResourceGroup ( context , subscription ) ;
194
207
} else {
195
208
return selected . data ! ;
196
209
}
@@ -200,7 +213,9 @@ export class AzurePickers extends Disposable {
200
213
await this . EnsureSignedIn ( ) ;
201
214
202
215
const client = await createSubscriptionClient ( [ context , createSubscriptionContext ( subscription ) ] ) ;
203
- const locations = ( await uiUtils . listAllIterator ( client . subscriptions . listLocations ( subscription . subscriptionId ) ) ) . map ( l => l . name ) ;
216
+ const locations = ( await uiUtils . listAllIterator ( client . subscriptions . listLocations ( subscription . subscriptionId ) ) ) . map ( l => nonNullProp ( l , "name" ) ) ;
217
+ locations . sort ( ) ;
218
+
204
219
const picks = locations . map ( ( l ) => < IAzureQuickPickItem < string > > {
205
220
label : l ,
206
221
data : l
@@ -213,23 +228,25 @@ export class AzurePickers extends Disposable {
213
228
await this . EnsureSignedIn ( ) ;
214
229
215
230
const managementGroupsAPI = new ManagementGroupsAPI ( new DefaultAzureCredential ( ) ) ;
216
- let managementGroupInfos : ManagementGroupInfo [ ] ;
231
+ let managementGroups : ManagementGroupInfo [ ] ;
217
232
try {
218
- managementGroupInfos = await uiUtils . listAllIterator ( managementGroupsAPI . managementGroups . list ( ) ) ;
233
+ managementGroups = await uiUtils . listAllIterator ( managementGroupsAPI . managementGroups . list ( ) ) ;
219
234
} catch ( err ) {
220
235
throw new Error ( `You might not have access to any management groups. Please create one in the Azure portal and try to deploy again. Error: ${ parseError ( err ) . message } ` ,
221
236
) ;
222
237
}
223
238
224
- const picks = managementGroupInfos . map ( ( mg ) => < IAzureQuickPickItem < ManagementGroupInfo > > {
239
+ managementGroups . sort ( ( a , b ) => nonNullProp ( a , "name" ) . localeCompare ( nonNullProp ( b , "name" ) ) ) ;
240
+
241
+ const picks = managementGroups . map ( ( mg ) => < IAzureQuickPickItem < ManagementGroupInfo > > {
225
242
label : mg . name ,
226
243
data : mg ,
227
244
} ) ;
228
245
229
246
return ( await context . ui . showQuickPick ( picks , { placeHolder : "Select management group" } ) ) . data ;
230
247
}
231
248
232
- private async promptAndCreateResourceGroup ( context : IActionContext , subscription : AzureSubscription ) : Promise < ResourceGroup > {
249
+ private async promptCreateResourceGroup ( context : IActionContext , subscription : AzureSubscription ) : Promise < ResourceGroup > {
233
250
const subscriptionContext = createSubscriptionContext ( subscription ) ;
234
251
const wizardContext : IResourceGroupWizardContext = {
235
252
...context ,
0 commit comments