Skip to content

Commit 62e23c6

Browse files
author
Lei Jin
committed
Update subscription client to 2021-01-01
1 parent eb271d8 commit 62e23c6

File tree

14 files changed

+188
-32
lines changed

14 files changed

+188
-32
lines changed

src/Accounts/Accounts.Test/AzureRMProfileTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using Microsoft.Azure.Commands.Profile.Models;
2121
using Microsoft.Azure.Commands.Profile.Test;
2222
using Microsoft.Azure.Commands.ScenarioTest;
23-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
23+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
2424
using Microsoft.Azure.ServiceManagement.Common.Models;
2525
using Microsoft.Rest;
2626
using Microsoft.Rest.Azure;
@@ -144,7 +144,7 @@ public void SpecifyTenantAndSubscriptionIdSucceed()
144144
null,
145145
false,
146146
null);
147-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
147+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
148148
}
149149

150150
[Fact]
@@ -179,7 +179,7 @@ public void SubscriptionIdNotExist()
179179
null,
180180
false,
181181
null));
182-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
182+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
183183
}
184184

185185
[Fact]

src/Accounts/Accounts.Test/AzureRMProfileTestsForMultitenant.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void LoginByTenant()
301301
false,
302302
null);
303303

304-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
304+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
305305
Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString());
306306
Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString());
307307
}
@@ -344,7 +344,7 @@ public void LoginBySubscriptionInMultitenantsHomeFirst()
344344
false,
345345
null);
346346

347-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
347+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
348348
Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString());
349349
Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString());
350350
}
@@ -390,7 +390,7 @@ public void LoginBySubscriptionInMultitenantsHomeSecond()
390390
false,
391391
null);
392392

393-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
393+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
394394
Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString());
395395
Assert.Equal(subscriptionA, azureRmProfile.DefaultContext.Subscription.Id.ToString());
396396
}
@@ -434,7 +434,7 @@ public void LoginBySubscriptionInManagedByTenants()
434434
false,
435435
null);
436436

437-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
437+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
438438
Assert.Equal(tenantB, azureRmProfile.DefaultContext.Tenant.Id.ToString());
439439
Assert.Equal(subscriptionC, azureRmProfile.DefaultContext.Subscription.Id.ToString());
440440
}
@@ -477,7 +477,7 @@ public void LoginBySubscriptionTenant()
477477
false,
478478
null);
479479

480-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
480+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
481481
Assert.Equal(tenantA, azureRmProfile.DefaultContext.Tenant.Id.ToString());
482482
Assert.Equal(subscriptionB, azureRmProfile.DefaultContext.Subscription.Id.ToString());
483483
}
@@ -591,7 +591,7 @@ public void SetContextByValidTenant()
591591
var client = GetProfileClient();
592592
var context = client.SetCurrentContext(null, tenantA);
593593

594-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
594+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
595595
Assert.Equal(tenantA, context.Tenant.Id.ToString());
596596
Assert.Equal(subscriptionA, context.Subscription.Id.ToString());
597597
}
@@ -627,7 +627,7 @@ public void SetContextBySubscriptionIdInHomeTenant()
627627
var client = GetProfileClient();
628628
var context = client.SetCurrentContext(subscriptionA, null);
629629

630-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
630+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
631631
Assert.Equal(tenantA, context.Tenant.Id.ToString());
632632
Assert.Equal(subscriptionA, context.Subscription.Id.ToString());
633633
}
@@ -664,7 +664,7 @@ public void SetContextBySubscriptionNameInHomeTenant()
664664
var client = GetProfileClient();
665665
var context = client.SetCurrentContext(subscriptionName.ToString(), null);
666666

667-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
667+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
668668
Assert.Equal(tenantA, context.Tenant.Id.ToString());
669669
Assert.Equal(subscriptionA, context.Subscription.Id.ToString());
670670
}
@@ -699,7 +699,7 @@ public void SetContextBySubscriptionInManagedByTenants()
699699
var client = GetProfileClient();
700700
var context = client.SetCurrentContext(subscriptionC.ToString(), null);
701701

702-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
702+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
703703
Assert.Equal(tenantA, context.Tenant.Id.ToString());
704704
Assert.Equal(subscriptionC, context.Subscription.Id.ToString());
705705
}
@@ -735,7 +735,7 @@ public void SetContextBySubscriptionTenant()
735735
var subscriptionName = (JObject.Parse(subscriptionListA[subscriptionB]))["displayName"];
736736
var context = client.SetCurrentContext(subscriptionName.ToString(), tenantA);
737737

738-
Assert.Equal("2019-06-01", client.SubscriptionAndTenantClient.ApiVersion);
738+
Assert.Equal("2021-01-01", client.SubscriptionAndTenantClient.ApiVersion);
739739
Assert.Equal(tenantA, context.Tenant.Id.ToString());
740740
Assert.Equal(subscriptionB, context.Subscription.Id.ToString());
741741
}

src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01;
16-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
15+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
16+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
1717
using Microsoft.Rest.Azure;
1818
using Moq;
1919
using System;

src/Accounts/Accounts.Test/Mocks/MockSubscriptionClientFactoryVersion2019.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01;
16-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
15+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
16+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
1717
using Microsoft.Rest.Azure;
1818
using Moq;
1919
using System;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/tenants?api-version=2021-01-01",
5+
"EncodedRequestUri": "L3RlbmFudHM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"x-ms-client-request-id": [
10+
"27447c0a-62f3-4ec5-a2ee-46d57196a6c5"
11+
],
12+
"Accept-Language": [
13+
"en-US"
14+
],
15+
"User-Agent": [
16+
"FxVersion/4.6.30015.01",
17+
"OSName/Windows",
18+
"OSVersion/Microsoft.Windows.10.0.19043.",
19+
"Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0"
20+
]
21+
},
22+
"ResponseHeaders": {
23+
"Cache-Control": [
24+
"no-cache"
25+
],
26+
"Pragma": [
27+
"no-cache"
28+
],
29+
"x-ms-ratelimit-remaining-tenant-reads": [
30+
"11999"
31+
],
32+
"x-ms-request-id": [
33+
"aa195b95-77d4-41fe-81ae-041fde762974"
34+
],
35+
"x-ms-correlation-request-id": [
36+
"aa195b95-77d4-41fe-81ae-041fde762974"
37+
],
38+
"x-ms-routing-request-id": [
39+
"SOUTHEASTASIA:20210628T075523Z:aa195b95-77d4-41fe-81ae-041fde762974"
40+
],
41+
"Strict-Transport-Security": [
42+
"max-age=31536000; includeSubDomains"
43+
],
44+
"X-Content-Type-Options": [
45+
"nosniff"
46+
],
47+
"Date": [
48+
"Mon, 28 Jun 2021 07:55:23 GMT"
49+
],
50+
"Content-Type": [
51+
"application/json; charset=utf-8"
52+
],
53+
"Expires": [
54+
"-1"
55+
],
56+
"Content-Length": [
57+
"140"
58+
]
59+
},
60+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/tenants/54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"tenantId\": \"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"tenantCategory\": \"Home\"\r\n }\r\n ]\r\n}",
61+
"StatusCode": 200
62+
},
63+
{
64+
"RequestUri": "/subscriptions?api-version=2021-01-01",
65+
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAyMS0wMS0wMQ==",
66+
"RequestMethod": "GET",
67+
"RequestBody": "",
68+
"RequestHeaders": {
69+
"x-ms-client-request-id": [
70+
"27447c0a-62f3-4ec5-a2ee-46d57196a6c5"
71+
],
72+
"Accept-Language": [
73+
"en-US"
74+
],
75+
"User-Agent": [
76+
"FxVersion/4.6.30015.01",
77+
"OSName/Windows",
78+
"OSVersion/Microsoft.Windows.10.0.19043.",
79+
"Microsoft.Azure.Management.ResourceManager.Version2021.01.01.SubscriptionClient/1.0.0.0"
80+
]
81+
},
82+
"ResponseHeaders": {
83+
"Cache-Control": [
84+
"no-cache"
85+
],
86+
"Pragma": [
87+
"no-cache"
88+
],
89+
"x-ms-ratelimit-remaining-tenant-reads": [
90+
"11999"
91+
],
92+
"x-ms-request-id": [
93+
"c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
94+
],
95+
"x-ms-correlation-request-id": [
96+
"c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
97+
],
98+
"x-ms-routing-request-id": [
99+
"SOUTHEASTASIA:20210628T075524Z:c8cf462f-f2c0-4ef4-8dc3-aee3d36d3293"
100+
],
101+
"Strict-Transport-Security": [
102+
"max-age=31536000; includeSubDomains"
103+
],
104+
"X-Content-Type-Options": [
105+
"nosniff"
106+
],
107+
"Date": [
108+
"Mon, 28 Jun 2021 07:55:23 GMT"
109+
],
110+
"Content-Type": [
111+
"application/json; charset=utf-8"
112+
],
113+
"Expires": [
114+
"-1"
115+
],
116+
"Content-Length": [
117+
"522"
118+
]
119+
},
120+
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590\",\r\n \"authorizationSource\": \"RoleBased\",\r\n \"managedByTenants\": [\r\n {\r\n \"tenantId\": \"2f4a9838-26b7-47ee-be60-ccc1fdec5953\"\r\n }\r\n ],\r\n \"tags\": {\r\n \"testTags\": \"testValue\"\r\n },\r\n \"subscriptionId\": \"0b1f6471-1bf0-4dda-aec3-cb9272f09590\",\r\n \"tenantId\": \"54826b22-38d6-4fb2-bad9-b7b93a3e9c5a\",\r\n \"displayName\": \"AzureSDKTest\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Internal_2014-09-01\",\r\n \"quotaId\": \"Internal_2014-09-01\",\r\n \"spendingLimit\": \"Off\"\r\n }\r\n }\r\n ],\r\n \"count\": {\r\n \"type\": \"Total\",\r\n \"value\": 1\r\n }\r\n}",
121+
"StatusCode": 200
122+
}
123+
],
124+
"Names": {},
125+
"Variables": {
126+
"SubscriptionId": "0b1f6471-1bf0-4dda-aec3-cb9272f09590"
127+
}
128+
}

src/Accounts/Accounts.Test/SubscriptionClientSwitchTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using Microsoft.Azure.Commands.Common.Authentication.Models;
1818
using Microsoft.Azure.Commands.Profile.Test.Mocks;
1919
using Microsoft.Azure.Commands.ScenarioTest;
20-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
20+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
2121
using Microsoft.Azure.ServiceManagement.Common.Models;
2222
using Microsoft.Rest.Azure;
2323
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;

src/Accounts/Accounts.Test/SubscriptionCmdletTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,12 @@ public void SetAzureRmContextWithoutSubscription()
5252
{
5353
TestRunner.RunTestScript("Test-SetAzureRmContextWithoutSubscription");
5454
}
55+
56+
[Fact]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void GetSubscriptionsWithTags()
59+
{
60+
TestRunner.RunTestScript("Test-GetSubscriptionsWithTags");
61+
}
5562
}
5663
}

src/Accounts/Accounts.Test/SubscriptionCmdletTests.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,16 @@ function Test-SetAzureRmContextWithoutSubscription
120120
Assert-True { $context.Tenant -ne $null }
121121
Assert-AreEqual $context.Tenant.Id $firstSubscription.HomeTenantId
122122
Assert-AreEqual $context.Subscription.Id $firstSubscription.Id
123-
}
123+
}
124+
125+
<#
126+
.SYNOPSIS
127+
Check whether tags works with subscripiton
128+
.DESCRIPTION
129+
SmokeTest
130+
#>
131+
function Test-GetSubscriptionsWithTags
132+
{
133+
$allSubscriptions = Get-AzSubscription
134+
Assert-True {($allSubscriptions | Where-Object { $_.Tags -ne $null}).Count -gt 0}
135+
}

src/Accounts/Accounts/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Added Tags, AuthorizationSource to PSAzureSusbscripiton and added TenantType, DefaultDomain, TenantBrandingLogoUrl, CountryCode to PSAzureTenant
23+
* Upgraded subscription client to 2021-01-01
2224
* Removed Interactive mode check in common lib
2325
* Added endpoint of OperationalInsights to environment AzureChinaCloud [#15305]
2426
* Printed auto generated modules' default logs to verbose stream

src/Accounts/Accounts/Models/SubscriptionClientProxy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
using System.Collections.Concurrent;
2121
using System.Threading;
2222
using SubscriptionClientVersion2016 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.SubscriptionClientWrapper;
23-
using SubscriptionClientVersion2019 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2019_06_01.SubscriptionClientWrapper;
23+
using SubscriptionClientVersion2021 = Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2021_01_01.SubscriptionClientWrapper;
2424

2525
namespace Microsoft.Azure.Commands.Profile.Models
2626
{
@@ -63,7 +63,7 @@ static public SubscritpionClientCandidates Instance
6363

6464
private SubscritpionClientCandidates()
6565
{
66-
Enqueue(new SubscriptionClientVersion2019());
66+
Enqueue(new SubscriptionClientVersion2021());
6767
Enqueue(new SubscriptionClientVersion2016());
6868
}
6969

src/Accounts/Accounts/Models/Version2016_06_01/SubscriptionClientWrapper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.Paging;
18-
using Microsoft.Azure.Commands.ResourceManager.Version2019_06_01.Customized;
1918
using Microsoft.Azure.Internal.Subscriptions;
2019
using Microsoft.Azure.Internal.Subscriptions.Models;
2120
using Microsoft.Azure.Internal.Subscriptions.Models.Utilities;

src/Accounts/Accounts/Models/Version2019_06_01/SubscriptionClientWrapper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
using Microsoft.Azure.Commands.Common.Authentication;
1616
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.Azure.Commands.ResourceManager.Common.Paging;
18-
using Microsoft.Azure.Commands.ResourceManager.Version2019_06_01.Customized;
19-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01;
20-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models;
21-
using Microsoft.Azure.Management.ResourceManager.Version2019_06_01.Models.Utilities;
18+
using Microsoft.Azure.Commands.ResourceManager.Version2021_01_01.Utilities;
19+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01;
20+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models;
21+
using Microsoft.Azure.Management.ResourceManager.Version2021_01_01.Models.Utilities;
2222
using Microsoft.Rest;
2323
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2424
using System.Collections.Generic;
2525
using System.Linq;
2626

27-
namespace Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2019_06_01
27+
namespace Microsoft.Azure.Commands.ResourceManager.Common.Utilities.Version2021_01_01
2828
{
2929
internal class SubscriptionClientWrapper : ISubscriptionClientWrapper
3030
{
3131
public SubscriptionClientWrapper()
3232
{
33-
ApiVersion = "2019-06-01";
33+
ApiVersion = "2021-01-01";
3434
}
3535

3636
public IList<AzureTenant> ListAccountTenants(IAccessToken accessToken, IAzureEnvironment environment)

src/Accounts/Authentication.ResourceManager/Models/PSAzureSubscription.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,13 @@ public static string GetAccountName(string connectionString)
210210

211211
return result;
212212
}
213+
214+
public Dictionary<string, string> Tags
215+
{
216+
get
217+
{
218+
return this.GetTags();
219+
}
220+
}
213221
}
214222
}

0 commit comments

Comments
 (0)