Skip to content

Commit 8b1f53d

Browse files
committed
Use get-azcontext to get the default subscriptionId.
1 parent 1751162 commit 8b1f53d

File tree

6 files changed

+92
-796
lines changed

6 files changed

+92
-796
lines changed

src/Resources/Resources.Test/ScenarioTests/TagTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ utility method to get default subscriptionId
253253
#>
254254
function GetDefaultSubscriptionId
255255
{
256-
$subs = Get-AzSubscription
257-
$subId = "/subscriptions/" + $subs[0].Id
256+
$context = Get-AzContext
257+
$subId = "/subscriptions/" + $context.Subscription.Id
258258

259259
return $subId
260260
}

src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.TagTests/TagCreateOrUpdateWithResourceIdParamsForSubscription.json

Lines changed: 15 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,13 @@
11
{
22
"Entries": [
3-
{
4-
"RequestUri": "/tenants?api-version=2016-06-01",
5-
"EncodedRequestUri": "L3RlbmFudHM/YXBpLXZlcnNpb249MjAxNi0wNi0wMQ==",
6-
"RequestMethod": "GET",
7-
"RequestBody": "",
8-
"RequestHeaders": {
9-
"x-ms-client-request-id": [
10-
"8eaa18a8-8a12-4485-83f6-6aa711973994"
11-
],
12-
"Accept-Language": [
13-
"en-US"
14-
],
15-
"User-Agent": [
16-
"FxVersion/4.6.27110.04",
17-
"OSName/Windows",
18-
"OSVersion/Microsoft.Windows.10.0.18363.",
19-
"Microsoft.Azure.Internal.Subscriptions.SubscriptionClient/1.3.7"
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-
"11997"
31-
],
32-
"x-ms-request-id": [
33-
"7e98815e-2970-4ad8-b084-472143d08a33"
34-
],
35-
"x-ms-correlation-request-id": [
36-
"7e98815e-2970-4ad8-b084-472143d08a33"
37-
],
38-
"x-ms-routing-request-id": [
39-
"WESTUS:20200226T003023Z:7e98815e-2970-4ad8-b084-472143d08a33"
40-
],
41-
"Strict-Transport-Security": [
42-
"max-age=31536000; includeSubDomains"
43-
],
44-
"X-Content-Type-Options": [
45-
"nosniff"
46-
],
47-
"Date": [
48-
"Wed, 26 Feb 2020 00:30:23 GMT"
49-
],
50-
"Content-Type": [
51-
"application/json; charset=utf-8"
52-
],
53-
"Expires": [
54-
"-1"
55-
],
56-
"Content-Length": [
57-
"116"
58-
],
59-
"Retry-After": [
60-
"0"
61-
]
62-
},
63-
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/tenants/72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"tenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\"\r\n }\r\n ]\r\n}",
64-
"StatusCode": 200
65-
},
66-
{
67-
"RequestUri": "/subscriptions?api-version=2016-06-01",
68-
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnM/YXBpLXZlcnNpb249MjAxNi0wNi0wMQ==",
69-
"RequestMethod": "GET",
70-
"RequestBody": "",
71-
"RequestHeaders": {
72-
"x-ms-client-request-id": [
73-
"e865418c-3f79-4983-a194-ecd9a1015174"
74-
],
75-
"Accept-Language": [
76-
"en-US"
77-
],
78-
"User-Agent": [
79-
"FxVersion/4.6.27110.04",
80-
"OSName/Windows",
81-
"OSVersion/Microsoft.Windows.10.0.18363.",
82-
"Microsoft.Azure.Internal.Subscriptions.SubscriptionClient/1.3.7"
83-
]
84-
},
85-
"ResponseHeaders": {
86-
"Cache-Control": [
87-
"no-cache"
88-
],
89-
"Pragma": [
90-
"no-cache"
91-
],
92-
"x-ms-ratelimit-remaining-tenant-reads": [
93-
"11996"
94-
],
95-
"x-ms-request-id": [
96-
"ca055c68-447c-40b7-bf1c-0e6fb9fd72b4"
97-
],
98-
"x-ms-correlation-request-id": [
99-
"ca055c68-447c-40b7-bf1c-0e6fb9fd72b4"
100-
],
101-
"x-ms-routing-request-id": [
102-
"WESTUS:20200226T003023Z:ca055c68-447c-40b7-bf1c-0e6fb9fd72b4"
103-
],
104-
"Strict-Transport-Security": [
105-
"max-age=31536000; includeSubDomains"
106-
],
107-
"X-Content-Type-Options": [
108-
"nosniff"
109-
],
110-
"Date": [
111-
"Wed, 26 Feb 2020 00:30:23 GMT"
112-
],
113-
"Content-Type": [
114-
"application/json; charset=utf-8"
115-
],
116-
"Expires": [
117-
"-1"
118-
],
119-
"Content-Length": [
120-
"337"
121-
],
122-
"Retry-After": [
123-
"0"
124-
]
125-
},
126-
"ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/b9f138a1-1d64-4108-8413-9ea3be1c1b2d\",\r\n \"authorizationSource\": \"RoleBased\",\r\n \"subscriptionId\": \"b9f138a1-1d64-4108-8413-9ea3be1c1b2d\",\r\n \"displayName\": \"Visual Studio Enterprise\",\r\n \"state\": \"Enabled\",\r\n \"subscriptionPolicies\": {\r\n \"locationPlacementId\": \"Public_2014-09-01\",\r\n \"quotaId\": \"MSDN_2014-09-01\",\r\n \"spendingLimit\": \"On\"\r\n }\r\n }\r\n ]\r\n}",
127-
"StatusCode": 200
128-
},
1293
{
1304
"RequestUri": "/%2Fsubscriptions%2Fb9f138a1-1d64-4108-8413-9ea3be1c1b2d/providers/Microsoft.Resources/tags/default?api-version=2019-10-01",
1315
"EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZiOWYxMzhhMS0xZDY0LTQxMDgtODQxMy05ZWEzYmUxYzFiMmQvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvdGFncy9kZWZhdWx0P2FwaS12ZXJzaW9uPTIwMTktMTAtMDE=",
1326
"RequestMethod": "PUT",
1337
"RequestBody": "{\r\n \"properties\": {\r\n \"tags\": {\r\n \"key1\": \"value1\",\r\n \"key2\": \"value2\"\r\n }\r\n }\r\n}",
1348
"RequestHeaders": {
1359
"x-ms-client-request-id": [
136-
"96dac2ce-172a-4458-8e15-9ec1547d3a01"
10+
"3ac6aa24-a05c-4d74-921a-870f10630548"
13711
],
13812
"Accept-Language": [
13913
"en-US"
@@ -162,13 +36,13 @@
16236
"1199"
16337
],
16438
"x-ms-request-id": [
165-
"9e917f84-ccad-4998-9afb-aa1cf731af65"
39+
"b61cccee-5cb4-4241-b824-92ac8a2176af"
16640
],
16741
"x-ms-correlation-request-id": [
168-
"9e917f84-ccad-4998-9afb-aa1cf731af65"
42+
"b61cccee-5cb4-4241-b824-92ac8a2176af"
16943
],
17044
"x-ms-routing-request-id": [
171-
"WESTUS:20200226T003024Z:9e917f84-ccad-4998-9afb-aa1cf731af65"
45+
"WESTUS:20200227T020326Z:b61cccee-5cb4-4241-b824-92ac8a2176af"
17246
],
17347
"Strict-Transport-Security": [
17448
"max-age=31536000; includeSubDomains"
@@ -177,7 +51,7 @@
17751
"nosniff"
17852
],
17953
"Date": [
180-
"Wed, 26 Feb 2020 00:30:23 GMT"
54+
"Thu, 27 Feb 2020 02:03:25 GMT"
18155
],
18256
"Content-Length": [
18357
"210"
@@ -202,7 +76,7 @@
20276
"RequestBody": "",
20377
"RequestHeaders": {
20478
"x-ms-client-request-id": [
205-
"a8e08168-2cf0-4157-85c1-9c45af3372dd"
79+
"4ac1dfb4-3588-4a88-abfe-17f74cb2f323"
20680
],
20781
"Accept-Language": [
20882
"en-US"
@@ -225,13 +99,13 @@
22599
"11999"
226100
],
227101
"x-ms-request-id": [
228-
"4cceec15-1413-4877-a924-31c73940fe18"
102+
"c4b68545-1a98-4e93-895a-3e5f44dbe3df"
229103
],
230104
"x-ms-correlation-request-id": [
231-
"4cceec15-1413-4877-a924-31c73940fe18"
105+
"c4b68545-1a98-4e93-895a-3e5f44dbe3df"
232106
],
233107
"x-ms-routing-request-id": [
234-
"WESTUS:20200226T003019Z:4cceec15-1413-4877-a924-31c73940fe18"
108+
"WESTUS:20200227T020326Z:c4b68545-1a98-4e93-895a-3e5f44dbe3df"
235109
],
236110
"Strict-Transport-Security": [
237111
"max-age=31536000; includeSubDomains"
@@ -240,7 +114,7 @@
240114
"nosniff"
241115
],
242116
"Date": [
243-
"Wed, 26 Feb 2020 00:30:19 GMT"
117+
"Thu, 27 Feb 2020 02:03:26 GMT"
244118
],
245119
"Content-Type": [
246120
"application/json; charset=utf-8"
@@ -265,7 +139,7 @@
265139
"RequestBody": "",
266140
"RequestHeaders": {
267141
"x-ms-client-request-id": [
268-
"016a6031-693c-4aa5-9f7d-a50f627c12b1"
142+
"0b0ab906-4b05-431d-8d32-d167735c5c50"
269143
],
270144
"Accept-Language": [
271145
"en-US"
@@ -288,13 +162,13 @@
288162
"14999"
289163
],
290164
"x-ms-request-id": [
291-
"c677a388-f848-4eaf-9622-5c8d67b0045b"
165+
"3c203eda-e0dc-4fae-9bf0-30ffccc6a92e"
292166
],
293167
"x-ms-correlation-request-id": [
294-
"c677a388-f848-4eaf-9622-5c8d67b0045b"
168+
"3c203eda-e0dc-4fae-9bf0-30ffccc6a92e"
295169
],
296170
"x-ms-routing-request-id": [
297-
"WESTUS:20200226T003020Z:c677a388-f848-4eaf-9622-5c8d67b0045b"
171+
"WESTUS:20200227T020327Z:3c203eda-e0dc-4fae-9bf0-30ffccc6a92e"
298172
],
299173
"Strict-Transport-Security": [
300174
"max-age=31536000; includeSubDomains"
@@ -303,7 +177,7 @@
303177
"nosniff"
304178
],
305179
"Date": [
306-
"Wed, 26 Feb 2020 00:30:20 GMT"
180+
"Thu, 27 Feb 2020 02:03:26 GMT"
307181
],
308182
"Expires": [
309183
"-1"

0 commit comments

Comments
 (0)