From dee067511af352d65d709794b678b9e5ca9d4297 Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Tue, 1 Sep 2020 15:35:17 -0700
Subject: [PATCH 1/9] New cmdlets
---
.../ScenarioTests/SubscriptionTests.cs | 28 +-
.../ScenarioTests/SubscriptionTests.ps1 | 46 ++--
.../TestGetSubscriptionAlias.json | 86 +++++++
.../TestNewSubscription.json | 243 ------------------
.../TestNewSubscriptionAlias.json | 92 +++++++
.../TestRemoveSubscriptionAlias.json | 80 ++++++
.../Subscription.Test.csproj | 2 +-
.../Subscription/Az.Subscription.psd1 | 2 +-
src/Subscription/Subscription/ChangeLog.md | 3 +
.../Cmdlets/GetAzureRmSubscriptionAlias.cs | 73 ++++++
.../Cmdlets/NewAzureRmSubscription.cs | 159 ------------
.../Cmdlets/NewAzureRmSubscriptionAlias.cs | 92 +++++++
.../Cmdlets/RemoveAzureRmSubscriptionAlias.cs | 60 +++++
.../Subscription/Subscription.csproj | 2 +-
.../Subscription/help/Az.Subscription.md | 14 +-
.../help/Get-AzSubscriptionAlias.md | 123 +++++++++
.../Subscription/help/New-AzSubscription.md | 203 ---------------
.../help/New-AzSubscriptionAlias.md | 184 +++++++++++++
.../help/Remove-AzSubscriptionAlias.md | 123 +++++++++
.../help/Update-AzSubscription.md | 4 +-
20 files changed, 982 insertions(+), 637 deletions(-)
create mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestGetSubscriptionAlias.json
delete mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
create mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscriptionAlias.json
create mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestRemoveSubscriptionAlias.json
create mode 100644 src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
delete mode 100644 src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
create mode 100644 src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
create mode 100644 src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
create mode 100644 src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
delete mode 100644 src/Subscription/Subscription/help/New-AzSubscription.md
create mode 100644 src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
create mode 100644 src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
index 29a2daa973b9..73921cd24bf1 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
@@ -34,13 +34,6 @@ public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
XunitTracingInterceptor.AddToContext(_logger);
TestExecutionHelpers.SetUpSessionAndProfile();
}
-
- [Fact]
- [Trait(Category.AcceptanceType, Category.CheckIn)]
- public void TestNewSubscription()
- {
- TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscription");
- }
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
@@ -55,5 +48,26 @@ public void TestUpdateCancelSubscription()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-UpdateCancelSubscription");
}
+
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void TestNewSubscriptionAlias()
+ {
+ TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscriptionAlias");
+ }
+
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void TestGetSubscriptionAlias()
+ {
+ TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSubscriptionAlias");
+ }
+
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void TestRemoveSubscriptionAlias()
+ {
+ TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveSubscriptionAlias");
+ }
}
}
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1 b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
index 2ca1936b9eb5..b29d58c7e596 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
@@ -16,22 +16,6 @@
.SYNOPSIS
Create subscription
#>
-function Test-NewSubscription
-{
- # $accounts = Get-AzEnrollmentAccount
- $accounts = @(@{ ObjectId = "455fd0a7-b04e-4a92-9e1b-d0650c8ba276" })
-
- # Verify the caller has at least one enrollment account.
- Assert-True { $accounts.Count -gt 0 }
-
- $myNewSubName = GetAssetName
-
- $newSub = New-AzSubscription -EnrollmentAccountObjectId $accounts[0].ObjectId -Name $myNewSubName -OfferType MS-AZR-0017P
-
- Assert-AreEqual $myNewSubName $newSub.Name
- Assert-NotNull $newSub.SubscriptionId
-}
-
function Test-UpdateRenameSubscription
{
$subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
@@ -49,3 +33,33 @@ function Test-UpdateCancelSubscription
Assert-NotNull updateSub.SubscriptionId
}
+
+function Test-NewSubscriptionAlias
+{
+ $aliasName = "navyprod1"
+ $displayName = "testSub1"
+ $billingScope ="billingScope"
+ $workload = "Production"
+
+ $newsub = New-AzSubscriptionAlias -AliasName $aliasName -SubscriptionName $displayName -BillingScope $billingScope -Workload $workload
+
+ Assert-NotNull newsub
+}
+
+function Test-GetSubscriptionAlias
+{
+ $aliasName = "navyprod1"
+
+ $newsub = Get-AzSubscriptionAlias -AliasName $aliasName
+
+ Assert-NotNull newsub
+}
+
+function Test-RemoveSubscriptionAlias
+{
+ $aliasName = "navyprod1"
+
+ $newsub = Remove-AzSubscriptionAlias -AliasName $aliasName
+
+ Assert-NotNull newsub
+}
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestGetSubscriptionAlias.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestGetSubscriptionAlias.json
new file mode 100644
index 000000000000..3cadc064b49f
--- /dev/null
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestGetSubscriptionAlias.json
@@ -0,0 +1,86 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Subscription/aliases/navyprod1?api-version=2020-09-01",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2FsaWFzZXMvbmF2eXByb2QxP2FwaS12ZXJzaW9uPTIwMjAtMDktMDE=",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "39c471c0-9fd7-434d-8947-38ed4d2be60f"
+ ],
+ "Accept-Language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "11999"
+ ],
+ "x-ms-correlation-request-id": [
+ "68f53ee5-2184-430d-90ff-f0afcf2d9b69"
+ ],
+ "request-id": [
+ "68f53ee5-2184-430d-90ff-f0afcf2d9b69"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-request-id": [
+ "68f53ee5-2184-430d-90ff-f0afcf2d9b69"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200901T220819Z:68f53ee5-2184-430d-90ff-f0afcf2d9b69"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Tue, 01 Sep 2020 22:08:18 GMT"
+ ],
+ "Content-Length": [
+ "222"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Subscription/aliases/navyprod1\",\r\n \"name\": \"navyprod1\",\r\n \"type\": \"Microsoft.Subscription/aliases\",\r\n \"properties\": {\r\n \"subscriptionId\": \"cef41c82-c4f0-48ae-a336-2ec44ec4375a\",\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}",
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
+ }
+}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
deleted file mode 100644
index 99d679ffe71e..000000000000
--- a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
+++ /dev/null
@@ -1,243 +0,0 @@
-{
- "Entries": [
- {
- "RequestUri": "/providers/Microsoft.Billing/enrollmentAccounts/455fd0a7-b04e-4a92-9e1b-d0650c8ba276/providers/Microsoft.Subscription/createSubscription?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9lbnJvbGxtZW50QWNjb3VudHMvNDU1ZmQwYTctYjA0ZS00YTkyLTllMWItZDA2NTBjOGJhMjc2L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2NyZWF0ZVN1YnNjcmlwdGlvbj9hcGktdmVyc2lvbj0yMDE5LTEwLTAxLXByZXZpZXc=",
- "RequestMethod": "POST",
- "RequestBody": "{\r\n \"displayName\": \"ps3132\",\r\n \"owners\": [],\r\n \"offerType\": \"MS-AZR-0017P\"\r\n}",
- "RequestHeaders": {
- "x-ms-client-request-id": [
- "3c3a8825-cfb3-40b5-9b5c-27080125a78d"
- ],
- "Accept-Language": [
- "en-US"
- ],
- "User-Agent": [
- "FxVersion/4.6.27817.03",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.18363.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Content-Length": [
- "80"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Location": [
- "https://management.azure.com/providers/Microsoft.Subscription/subscriptionOperations/ZWYzZGRkOWUtNDljMy00MWI2LWE2MjEtZDM4YTQ0ZjA3NzU1?api-version=2019-10-01-preview"
- ],
- "Retry-After": [
- "30"
- ],
- "x-ms-correlation-request-id": [
- "7b8de195-e00a-498a-ae44-8d73cd574b67"
- ],
- "request-id": [
- "7b8de195-e00a-498a-ae44-8d73cd574b67"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-ratelimit-remaining-tenant-resource-requests": [
- "499"
- ],
- "x-ms-request-id": [
- "7b8de195-e00a-498a-ae44-8d73cd574b67"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200622T192222Z:7b8de195-e00a-498a-ae44-8d73cd574b67"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Mon, 22 Jun 2020 19:22:21 GMT"
- ],
- "Content-Length": [
- "2"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{}",
- "StatusCode": 202
- },
- {
- "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/ZWYzZGRkOWUtNDljMy00MWI2LWE2MjEtZDM4YTQ0ZjA3NzU1?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvWldZelpHUmtPV1V0TkRsak15MDBNV0kyTFdFMk1qRXRaRE00WVRRMFpqQTNOelUxP2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
- "RequestMethod": "GET",
- "RequestBody": "",
- "RequestHeaders": {
- "User-Agent": [
- "FxVersion/4.6.27817.03",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.18363.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Vary": [
- "Accept-Encoding"
- ],
- "x-ms-ratelimit-remaining-tenant-reads": [
- "11999"
- ],
- "x-ms-correlation-request-id": [
- "098ee31c-ad4b-40af-a9ca-ba18c58ff94b"
- ],
- "request-id": [
- "098ee31c-ad4b-40af-a9ca-ba18c58ff94b"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-request-id": [
- "098ee31c-ad4b-40af-a9ca-ba18c58ff94b"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200622T192252Z:098ee31c-ad4b-40af-a9ca-ba18c58ff94b"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Mon, 22 Jun 2020 19:22:52 GMT"
- ],
- "Content-Length": [
- "74"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/ef3ddd9e-49c3-41b6-a621-d38a44f07755\"\r\n}",
- "StatusCode": 200
- },
- {
- "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/ZWYzZGRkOWUtNDljMy00MWI2LWE2MjEtZDM4YTQ0ZjA3NzU1?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvWldZelpHUmtPV1V0TkRsak15MDBNV0kyTFdFMk1qRXRaRE00WVRRMFpqQTNOelUxP2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
- "RequestMethod": "GET",
- "RequestBody": "",
- "RequestHeaders": {
- "User-Agent": [
- "FxVersion/4.6.27817.03",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.18363.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Vary": [
- "Accept-Encoding"
- ],
- "x-ms-ratelimit-remaining-tenant-reads": [
- "11998"
- ],
- "x-ms-correlation-request-id": [
- "b81e5f48-9d6d-4b7e-969e-8a764b0ad84a"
- ],
- "request-id": [
- "b81e5f48-9d6d-4b7e-969e-8a764b0ad84a"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-request-id": [
- "b81e5f48-9d6d-4b7e-969e-8a764b0ad84a"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200622T192253Z:b81e5f48-9d6d-4b7e-969e-8a764b0ad84a"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Mon, 22 Jun 2020 19:22:52 GMT"
- ],
- "Content-Length": [
- "74"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/ef3ddd9e-49c3-41b6-a621-d38a44f07755\"\r\n}",
- "StatusCode": 200
- }
- ],
- "Names": {
- "Test-NewSubscription": [
- "ps3132"
- ]
- },
- "Variables": {
- "SubscriptionId": "21cba39d-cbbc-487f-9749-43c5c960f269"
- }
-}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscriptionAlias.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscriptionAlias.json
new file mode 100644
index 000000000000..577e56c14d85
--- /dev/null
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscriptionAlias.json
@@ -0,0 +1,92 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Subscription/aliases/navyprod1?api-version=2020-09-01",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2FsaWFzZXMvbmF2eXByb2QxP2FwaS12ZXJzaW9uPTIwMjAtMDktMDE=",
+ "RequestMethod": "PUT",
+ "RequestBody": "{\r\n \"properties\": {\r\n \"displayName\": \"testSub1\",\r\n \"workload\": \"Production\",\r\n \"billingScope\": \"billingScope\"\r\n }\r\n}",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "754fdc06-4e5e-4331-bfb1-8a699ac22fe0"
+ ],
+ "Accept-Language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Content-Length": [
+ "127"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-writes": [
+ "1199"
+ ],
+ "x-ms-correlation-request-id": [
+ "ad1c5637-1edc-4f54-80af-b26289a4502a"
+ ],
+ "request-id": [
+ "ad1c5637-1edc-4f54-80af-b26289a4502a"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-request-id": [
+ "ad1c5637-1edc-4f54-80af-b26289a4502a"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200901T212110Z:ad1c5637-1edc-4f54-80af-b26289a4502a"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Tue, 01 Sep 2020 21:21:10 GMT"
+ ],
+ "Content-Length": [
+ "222"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Subscription/aliases/navyprod1\",\r\n \"name\": \"navyprod1\",\r\n \"type\": \"Microsoft.Subscription/aliases\",\r\n \"properties\": {\r\n \"subscriptionId\": \"cef41c82-c4f0-48ae-a336-2ec44ec4375a\",\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}",
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
+ }
+}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestRemoveSubscriptionAlias.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestRemoveSubscriptionAlias.json
new file mode 100644
index 000000000000..8920d763e60c
--- /dev/null
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestRemoveSubscriptionAlias.json
@@ -0,0 +1,80 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Subscription/aliases/navyprod1?api-version=2020-09-01",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2FsaWFzZXMvbmF2eXByb2QxP2FwaS12ZXJzaW9uPTIwMjAtMDktMDE=",
+ "RequestMethod": "DELETE",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "7877be7d-8890-43d9-9828-8ffb4f941e76"
+ ],
+ "Accept-Language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "x-ms-correlation-request-id": [
+ "eb016bf5-6e93-468d-9408-a05245da5f3f"
+ ],
+ "request-id": [
+ "eb016bf5-6e93-468d-9408-a05245da5f3f"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-deletes": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "eb016bf5-6e93-468d-9408-a05245da5f3f"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200901T220831Z:eb016bf5-6e93-468d-9408-a05245da5f3f"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Tue, 01 Sep 2020 22:08:31 GMT"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Content-Length": [
+ "0"
+ ]
+ },
+ "ResponseBody": "",
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
+ }
+}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/Subscription.Test.csproj b/src/Subscription/Subscription.Test/Subscription.Test.csproj
index 89fa3267df76..36ef0fcc029b 100644
--- a/src/Subscription/Subscription.Test/Subscription.Test.csproj
+++ b/src/Subscription/Subscription.Test/Subscription.Test.csproj
@@ -11,7 +11,7 @@
-
+
\ No newline at end of file
diff --git a/src/Subscription/Subscription/Az.Subscription.psd1 b/src/Subscription/Subscription/Az.Subscription.psd1
index a9dc6d4ee802..24f9a1bd37a9 100644
--- a/src/Subscription/Subscription/Az.Subscription.psd1
+++ b/src/Subscription/Subscription/Az.Subscription.psd1
@@ -72,7 +72,7 @@ NestedModules = @('Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll')
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-CmdletsToExport = 'New-AzSubscription', 'Update-AzSubscription'
+CmdletsToExport = 'Update-AzSubscription','New-AzSubscriptionAlias','Get-AzSubscriptionAlias','Remove-AzSubscriptionAlias'
# Variables to export from this module
# VariablesToExport = @()
diff --git a/src/Subscription/Subscription/ChangeLog.md b/src/Subscription/Subscription/ChangeLog.md
index 27cc514aab82..5c0f7028e04e 100644
--- a/src/Subscription/Subscription/ChangeLog.md
+++ b/src/Subscription/Subscription/ChangeLog.md
@@ -19,6 +19,9 @@
-->
## Upcoming Release
+## Version 0.7.4
+* Added new cmdlets `New-AzSubscriptionAlias`, deprecating cmdlet `New-AzSubscription`
+
## Version 0.7.3
* Added new cmdlet `Update-AzSubscription`
diff --git a/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
new file mode 100644
index 000000000000..5cae530d2178
--- /dev/null
+++ b/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
@@ -0,0 +1,73 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System.Management.Automation;
+using Microsoft.Azure.Commands.Common.Authentication;
+using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.Commands.ResourceManager.Common;
+using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
+using Microsoft.Azure.Commands.Subscription.Models;
+using Microsoft.Azure.Management.Subscription;
+using Microsoft.Azure.Management.Subscription.Models;
+
+namespace Microsoft.Azure.Commands.Subscription.Cmdlets
+{
+ [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SubscriptionAlias", SupportsShouldProcess =
+ true), OutputType(typeof(PSAzureSubscription))]
+ public class GetAzureRmSubscriptionAlias : AzureRmLongRunningCmdlet
+ {
+ private ISubscriptionClient _subscriptionClient;
+
+ ///
+ /// Gets or sets the subscription client.
+ ///
+ public ISubscriptionClient SubscriptionClient
+ {
+ get
+ {
+ return _subscriptionClient ??
+ (_subscriptionClient =
+ AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
+ AzureEnvironment.Endpoint.ResourceManager));
+ }
+ set { _subscriptionClient = value; }
+ }
+
+ [Parameter(Mandatory = false, HelpMessage = "Alias for the subscription")]
+ public string AliasName { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ if (this.ShouldProcess(target: this.AliasName, action: "Get subscription Alias"))
+ {
+ if (AliasName != null)
+ {
+ PutAliasResponse result = new PutAliasResponse();
+
+ result = this.SubscriptionClient.Alias.Get(AliasName);
+
+ WriteObject(result);
+ }
+ else
+ {
+ PutAliasListResult result = new PutAliasListResult();
+
+ result = this.SubscriptionClient.Alias.List();
+
+ WriteObject(result);
+ }
+ }
+ }
+ }
+}
diff --git a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
deleted file mode 100644
index 27764e87bee7..000000000000
--- a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-using Microsoft.Azure.Commands.Common.Authentication;
-using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
-using Microsoft.Azure.Commands.ResourceManager.Common;
-using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
-using Microsoft.Azure.Commands.Subscription.Models;
-using Microsoft.Azure.Graph.RBAC.Version1_6;
-using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
-using Microsoft.Azure.Graph.RBAC.Version1_6.Models;
-using Microsoft.Azure.Management.Subscription;
-using Microsoft.Azure.Management.Subscription.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Management.Automation;
-
-namespace Microsoft.Azure.Commands.Subscription.Cmdlets
-{
- [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Subscription", SupportsShouldProcess = true), OutputType(typeof(PSAzureSubscription))]
- public class NewAzureRmSubscription : AzureRmLongRunningCmdlet
- {
- private ActiveDirectoryClient _activeDirectoryClient;
- private ISubscriptionClient _subscriptionClient;
-
- public ActiveDirectoryClient ActiveDirectoryClient
- {
- get
- {
- if (_activeDirectoryClient == null)
- {
- _activeDirectoryClient = new ActiveDirectoryClient(DefaultContext);
- }
- return this._activeDirectoryClient;
- }
-
- set { this._activeDirectoryClient = value; }
- }
-
- ///
- /// Gets or sets the subscription client.
- ///
- public ISubscriptionClient SubscriptionClient
- {
- get
- {
- return _subscriptionClient ??
- (_subscriptionClient =
- AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
- AzureEnvironment.Endpoint.ResourceManager));
- }
- set { _subscriptionClient = value; }
- }
-
- [Parameter(Mandatory = true, HelpMessage = "Name of the enrollment account to use when creating the subscription.")]
- public string EnrollmentAccountObjectId { get; set; }
-
- [Parameter(Mandatory = false, Position = 0, HelpMessage = "Name of the subscription. When not specified, a name will be generated based on the specified offer type.")]
- public string Name { get; set; }
-
- [Parameter(Mandatory = true, HelpMessage = "Offer type of the subscription.")]
- [PSArgumentCompleter("MS-AZR-0017P", "MS-AZR-0148P")]
- public string OfferType { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The user(s) or group object(s) id(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerId", "OwnerPrincipalId")]
- public string[] OwnerObjectId { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The user(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerEmail", "OwnerUserPrincipalName")]
- public string[] OwnerSignInName { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The app SPN(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerSPN", "OwnerServicePrincipalName")]
- public string[] OwnerApplicationId { get; set; }
-
- public override void ExecuteCmdlet()
- {
- if (this.ShouldProcess(target: this.Name, action: "Create subscription"))
- {
- SubscriptionCreationResult result = new SubscriptionCreationResult();
-
- var owners = this
- .ResolveObjectIds(this.OwnerObjectId, this.OwnerApplicationId, this.OwnerSignInName)
- .Select(id => new AdPrincipal() { ObjectId = id }).ToArray();
-
- // Create the subscription.
- result = this.SubscriptionClient.Subscription.CreateSubscriptionInEnrollmentAccount(
- EnrollmentAccountObjectId, new SubscriptionCreationParameters()
- {
- DisplayName = this.Name,
- OfferType = this.OfferType,
- Owners = owners
- });
-
- // Write output.
- var createdSubscription = new AzureSubscription()
- {
- // SubscriptionLink format is: "/subscriptions/{subscriptionid}"
- Id = result.SubscriptionLink.Split('/')[2],
- Name = this.Name,
- // By definition, a new subscription is always in the enabled state.
- State = "Enabled",
- };
- createdSubscription.SetTenant(DefaultContext.Tenant.Id);
- WriteObject(new PSAzureSubscription(createdSubscription));
- }
- }
-
- private string[] ResolveObjectIds(string[] objectIds, string[] servicePrincipalNames, string[] userPrincipalNames)
- {
- var uniqueObjectIds = new HashSet(objectIds?.Select(id => Guid.Parse(id)) ?? new Guid[0]);
-
- if (servicePrincipalNames != null)
- {
- foreach (string spn in servicePrincipalNames)
- {
- uniqueObjectIds.Add(ActiveDirectoryClient.GetObjectIdFromSPN(spn));
- }
- }
-
- if (userPrincipalNames != null)
- {
- foreach (string upn in userPrincipalNames)
- {
- // TODO: Revert once available: uniqueObjectIds.Add(Guid.Parse(ActiveDirectoryClient.GetObjectIdFromUPN(upn)));
- uniqueObjectIds.Add(Guid.Parse(GetObjectIdFromUPN(ActiveDirectoryClient, upn)));
- }
- }
-
- return uniqueObjectIds.Select(id => id.ToString()).ToArray();
- }
-
- // Temporary until this code has moved into ActiveDirectoryClient.
- private static string GetObjectIdFromUPN(ActiveDirectoryClient activeDirectoryClient, string upn)
- {
- var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.UserPrincipalName == upn);
- var user = activeDirectoryClient.GraphClient.Users.List(odataQueryFilter.ToString()).SingleOrDefault();
- if (user == null)
- {
- throw new InvalidOperationException(String.Format("User with UPN '{0}' does not exist.", upn));
- }
-
- return user.ObjectId;
- }
- }
-}
diff --git a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
new file mode 100644
index 000000000000..790bb4bb89e9
--- /dev/null
+++ b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
@@ -0,0 +1,92 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System.Management.Automation;
+using Microsoft.Azure.Commands.Common.Authentication;
+using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.Commands.ResourceManager.Common;
+using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
+using Microsoft.Azure.Commands.Subscription.Models;
+using Microsoft.Azure.Management.Subscription;
+using Microsoft.Azure.Management.Subscription.Models;
+
+namespace Microsoft.Azure.Commands.Subscription.Cmdlets
+{
+ [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SubscriptionAlias", SupportsShouldProcess =
+ true), OutputType(typeof(PSAzureSubscription))]
+ public class NewAzureRmSubscriptionAlias : AzureRmLongRunningCmdlet
+ {
+ private ISubscriptionClient _subscriptionClient;
+
+ ///
+ /// Gets or sets the subscription client.
+ ///
+ public ISubscriptionClient SubscriptionClient
+ {
+ get
+ {
+ return _subscriptionClient ??
+ (_subscriptionClient =
+ AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
+ AzureEnvironment.Endpoint.ResourceManager));
+ }
+ set { _subscriptionClient = value; }
+ }
+
+ [Parameter(Mandatory = true, HelpMessage = "Alias for the subscription")]
+ public string AliasName { get; set; }
+
+ [Parameter(Mandatory = true, HelpMessage = "Billing Scope")]
+ public string BillingScope { get; set; }
+
+ [Parameter(Mandatory = true, HelpMessage = "Type of Workload")]
+ [PSArgumentCompleter("Production", "DevTest")]
+ public string Workload { get; set; }
+
+ [Parameter(Mandatory = true, HelpMessage = "Name of the subscription")]
+ public string SubscriptionName { get; set; }
+
+ [Parameter(Mandatory = false, HelpMessage = "Existing Subscription Id")]
+ public string SubscriptionId { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ if (this.ShouldProcess(target: this.AliasName, action: "New subscription Alias"))
+ {
+ PutAliasResponse result = new PutAliasResponse();
+
+ // Create the subscription.
+ result = this.SubscriptionClient.Alias.Create(
+ AliasName, new PutAliasRequest()
+ {
+ Properties = new PutAliasRequestProperties()
+ {
+ BillingScope = BillingScope,
+ Workload = Workload,
+ DisplayName = SubscriptionName,
+ SubscriptionId = SubscriptionId
+ }
+ });
+
+ // Write output.
+ var createdSubscription = new AzureSubscription()
+ {
+ Id = result.Properties.SubscriptionId
+ };
+
+ WriteObject(new PSAzureSubscription(createdSubscription));
+ }
+ }
+ }
+}
diff --git a/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
new file mode 100644
index 000000000000..63f9dfea73ed
--- /dev/null
+++ b/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
@@ -0,0 +1,60 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using System.Management.Automation;
+using Microsoft.Azure.Commands.Common.Authentication;
+using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.Commands.ResourceManager.Common;
+using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
+using Microsoft.Azure.Commands.Subscription.Models;
+using Microsoft.Azure.Management.Subscription;
+using Microsoft.Azure.Management.Subscription.Models;
+
+namespace Microsoft.Azure.Commands.Subscription.Cmdlets
+{
+ [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SubscriptionAlias", SupportsShouldProcess =
+ true), OutputType(typeof(PSAzureSubscription))]
+ public class RemoveAzureRmSubscriptionAlias : AzureRmLongRunningCmdlet
+ {
+ private ISubscriptionClient _subscriptionClient;
+
+ ///
+ /// Gets or sets the subscription client.
+ ///
+ public ISubscriptionClient SubscriptionClient
+ {
+ get
+ {
+ return _subscriptionClient ??
+ (_subscriptionClient =
+ AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
+ AzureEnvironment.Endpoint.ResourceManager));
+ }
+ set { _subscriptionClient = value; }
+ }
+
+ [Parameter(Mandatory = true, HelpMessage = "Alias for the subscription")]
+ public string AliasName { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ if (this.ShouldProcess(target: this.AliasName, action: "Delete subscription Alias"))
+ {
+ this.SubscriptionClient.Alias.Delete(AliasName);
+ string result = "Alias Deleted";
+ WriteObject(result);
+ }
+ }
+ }
+}
diff --git a/src/Subscription/Subscription/Subscription.csproj b/src/Subscription/Subscription/Subscription.csproj
index 55c5e1a448fb..ed379c9cbbc0 100644
--- a/src/Subscription/Subscription/Subscription.csproj
+++ b/src/Subscription/Subscription/Subscription.csproj
@@ -11,7 +11,7 @@
-
+
\ No newline at end of file
diff --git a/src/Subscription/Subscription/help/Az.Subscription.md b/src/Subscription/Subscription/help/Az.Subscription.md
index eecaf681bd34..963656591a8d 100644
--- a/src/Subscription/Subscription/help/Az.Subscription.md
+++ b/src/Subscription/Subscription/help/Az.Subscription.md
@@ -11,9 +11,15 @@ Locale: en-US
The topics in this section document the Azure PowerShell cmdlets for Azure Subscription in the Azure Resource Manager (ARM) framework. The cmdlets exist in the Microsoft.Azure.Commands.Subscription namespace.
## Az.Subscription Cmdlets
-### [New-AzSubscription](New-AzSubscription.md)
-Creates an Azure subscription.
-
### [Update-AzSubscription](Update-AzSubscription.md)
-Updates the Azure subscription
+Updates an Azure Subscription
+
+### [New-AzSubscriptionAlias](New-AzSubscriptionAlias.md)
+Creates new Alias and Subscription
+
+### [Get-AzSubscriptionAlias](Get-AzSubscriptionAlias.md)
+Gets subscription alias details
+
+### [Remove-AzSubscriptionAlias](Remove-AzSubscriptionAlias.md)
+Remove subscription alias
diff --git a/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
new file mode 100644
index 000000000000..227d5f53db4a
--- /dev/null
+++ b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
@@ -0,0 +1,123 @@
+---
+external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
+Module Name: Az.Subscription
+online version:
+schema: 2.0.0
+---
+
+# Get-AzSubscriptionAlias
+
+## SYNOPSIS
+Gets subscription alias details
+
+## SYNTAX
+
+```
+Get-AzSubscriptionAlias [-AliasName ] [-AsJob] [-DefaultProfile ] [-WhatIf]
+ [-Confirm] []
+```
+
+## DESCRIPTION
+The **Get-AzSubscriptionAlias** cmdlet gets subscription alias details.
+
+## EXAMPLES
+
+### Example 1
+```powershell
+PS C:\> Get-AzSubscriptionAlias -AliasName "ExistingAliasName"
+```
+
+Gets subscription alias details
+
+## PARAMETERS
+
+### -AliasName
+Alias for the subscription
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -AsJob
+Run cmdlet in the background
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -DefaultProfile
+The credentials, account, tenant, and subscription used for communication with Azure.
+
+```yaml
+Type: IAzureContextContainer
+Parameter Sets: (All)
+Aliases: AzContext, AzureRmContext, AzureCredential
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Confirm
+Prompts you for confirmation before running the cmdlet.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: cf
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -WhatIf
+Shows what would happen if the cmdlet runs.
+The cmdlet is not run.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: wi
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+### None
+
+## OUTPUTS
+
+### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
+
+## NOTES
+
+## RELATED LINKS
diff --git a/src/Subscription/Subscription/help/New-AzSubscription.md b/src/Subscription/Subscription/help/New-AzSubscription.md
deleted file mode 100644
index 79fca2c01aba..000000000000
--- a/src/Subscription/Subscription/help/New-AzSubscription.md
+++ /dev/null
@@ -1,203 +0,0 @@
----
-external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
-Module Name: Az.Subscription
-online version: https://docs.microsoft.com/en-us/powershell/module/az.subscription/new-azsubscription
-schema: 2.0.0
----
-
-# New-AzSubscription
-
-## SYNOPSIS
-Creates an Azure subscription.
-
-## SYNTAX
-
-```
-New-AzSubscription -EnrollmentAccountObjectId [[-Name] ] -OfferType
- [-OwnerObjectId ] [-OwnerSignInName ] [-OwnerApplicationId ] [-AsJob]
- [-DefaultProfile ] [-WhatIf] [-Confirm] []
-```
-
-## DESCRIPTION
-The **New-AzSubscription** cmdlet creates an Azure subscription.
-
-## EXAMPLES
-
-### Example 1
-```
-PS C:\> New-AzSubscription -Name "My Subscription" -EnrollmentAccountObjectId ((Get-AzEnrollmentAccount)[0].ObjectId) -OfferType MS-AZR-0017P
-
-Name : My Subscription
-Id : 86869d42-1782-4337-98b0-c905fb937d46
-TenantId : a5dcb057-fd83-4384-9d49-5198004d33a5
-State : Enabled
-```
-
-Creates an Azure subscription under the specified enrollment account with the specified offer type.
-
-## PARAMETERS
-
-### -AsJob
-Run cmdlet in the background
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases:
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -DefaultProfile
-The credentials, account, tenant, and subscription used for communication with Azure.
-
-```yaml
-Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
-Parameter Sets: (All)
-Aliases: AzContext, AzureRmContext, AzureCredential
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -EnrollmentAccountObjectId
-Name of the enrollment account to use when creating the subscription.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: True
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -Name
-The name of the subscription to create.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: False
-Position: 0
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OfferType
-The type of offer to use when creating the subscription.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: True
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerApplicationId
-The app SPN(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerSPN, OwnerServicePrincipalName
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerObjectId
-The user(s) or group object(s) id(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerId, OwnerPrincipalId
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerSignInName
-The user(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerEmail, OwnerUserPrincipalName
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -Confirm
-Prompts you for confirmation before running the cmdlet.
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases: cf
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -WhatIf
-Shows what would happen if the cmdlet runs. The cmdlet is not run.
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases: wi
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
-
-## INPUTS
-
-### None
-
-## OUTPUTS
-
-### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
-
-## NOTES
-
-## RELATED LINKS
diff --git a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
new file mode 100644
index 000000000000..31504c1e67ea
--- /dev/null
+++ b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
@@ -0,0 +1,184 @@
+---
+external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
+Module Name: Az.Subscription
+online version:
+schema: 2.0.0
+---
+
+# New-AzSubscriptionAlias
+
+## SYNOPSIS
+Creates new alias and subscription
+
+## SYNTAX
+
+```
+New-AzSubscriptionAlias -AliasName -BillingScope -Workload
+ -SubscriptionName [-SubscriptionId ] [-AsJob] [-DefaultProfile ]
+ [-WhatIf] [-Confirm] []
+```
+
+## DESCRIPTION
+The **New-AzSubscriptionAlias** cmdlet creates new alias and subscription
+
+## EXAMPLES
+
+### Example 1
+```powershell
+PS C:\> New-AzSubscriptionAlias -AliasName "NewAliasName" -SubscriptionName "SubscriptionName" -BillingScope "BillingScope" -Workload "WorkloadType"
+```
+
+Creates new alias and subscription
+
+## PARAMETERS
+
+### -AliasName
+Alias for the subscription
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -AsJob
+Run cmdlet in the background
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -BillingScope
+Billing Scope
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -DefaultProfile
+The credentials, account, tenant, and subscription used for communication with Azure.
+
+```yaml
+Type: IAzureContextContainer
+Parameter Sets: (All)
+Aliases: AzContext, AzureRmContext, AzureCredential
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -SubscriptionId
+Existing Subscription Id
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -SubscriptionName
+Name of the subscription
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Workload
+Type of Workload
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Confirm
+Prompts you for confirmation before running the cmdlet.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: cf
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -WhatIf
+Shows what would happen if the cmdlet runs.
+The cmdlet is not run.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: wi
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+### None
+
+## OUTPUTS
+
+### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
+
+## NOTES
+
+## RELATED LINKS
diff --git a/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
new file mode 100644
index 000000000000..687bc7813dab
--- /dev/null
+++ b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
@@ -0,0 +1,123 @@
+---
+external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
+Module Name: Az.Subscription
+online version:
+schema: 2.0.0
+---
+
+# Remove-AzSubscriptionAlias
+
+## SYNOPSIS
+Deletes the subscription alias
+
+## SYNTAX
+
+```
+Remove-AzSubscriptionAlias -AliasName [-AsJob] [-DefaultProfile ] [-WhatIf]
+ [-Confirm] []
+```
+
+## DESCRIPTION
+The **Remove-AzSubscriptionAlias** cmdlet removes the subscription alias
+
+## EXAMPLES
+
+### Example 1
+```powershell
+PS C:\> Remove-AzSubscriptionAlias -AliasName "ExistingAliasName"
+```
+
+Deletes the subscription alias
+
+## PARAMETERS
+
+### -AliasName
+Alias for the subscription
+
+```yaml
+Type: String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -AsJob
+Run cmdlet in the background
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -DefaultProfile
+The credentials, account, tenant, and subscription used for communication with Azure.
+
+```yaml
+Type: IAzureContextContainer
+Parameter Sets: (All)
+Aliases: AzContext, AzureRmContext, AzureCredential
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Confirm
+Prompts you for confirmation before running the cmdlet.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: cf
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -WhatIf
+Shows what would happen if the cmdlet runs.
+The cmdlet is not run.
+
+```yaml
+Type: SwitchParameter
+Parameter Sets: (All)
+Aliases: wi
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+### None
+
+## OUTPUTS
+
+### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
+
+## NOTES
+
+## RELATED LINKS
diff --git a/src/Subscription/Subscription/help/Update-AzSubscription.md b/src/Subscription/Subscription/help/Update-AzSubscription.md
index 617946a92219..fdcfa0ba6a19 100644
--- a/src/Subscription/Subscription/help/Update-AzSubscription.md
+++ b/src/Subscription/Subscription/help/Update-AzSubscription.md
@@ -1,7 +1,7 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
Module Name: Az.Subscription
-online version:https://docs.microsoft.com/en-us/powershell/module/az.subscription/update-azsubscription
+online version: https://docs.microsoft.com/en-us/powershell/module/az.subscription/update-azsubscription
schema: 2.0.0
---
@@ -30,8 +30,8 @@ Name : My Subscription
Id : 86869d42-1782-4337-98b0-c905fb937d46
TenantId : a5dcb057-fd83-4384-9d49-5198004d33a5
State : Enabled
-
```
+
Updates the subscription
## PARAMETERS
From 0e7bb63633f30ac3f474ae859a44b63e2cdac263 Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Wed, 2 Sep 2020 13:37:15 -0700
Subject: [PATCH 2/9] Adding new create sub cmdlets
---
.../ScenarioTests/SubscriptionTests.cs | 7 +
.../ScenarioTests/SubscriptionTests.ps1 | 16 ++
.../TestNewSubscription.json | 243 ++++++++++++++++++
.../Subscription.Test.csproj | 2 +-
src/Subscription/Subscription.sln | 6 +
.../Subscription/Az.Subscription.psd1 | 2 +-
src/Subscription/Subscription/ChangeLog.md | 2 +-
.../Cmdlets/NewAzureRmSubscription.cs | 145 +++++++++++
.../Subscription/Subscription.csproj | 4 +
.../Subscription/help/Az.Subscription.md | 3 +
.../Subscription/help/New-AzSubscription.md | 203 +++++++++++++++
.../SubscriptionPreview/LegacySubscription.cs | 56 ++++
.../SubscriptionPreview.csproj | 15 ++
13 files changed, 701 insertions(+), 3 deletions(-)
create mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
create mode 100644 src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
create mode 100644 src/Subscription/Subscription/help/New-AzSubscription.md
create mode 100644 src/Subscription/SubscriptionPreview/LegacySubscription.cs
create mode 100644 src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
index 73921cd24bf1..d9401aee96b6 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
@@ -35,6 +35,13 @@ public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
TestExecutionHelpers.SetUpSessionAndProfile();
}
+ [Fact]
+ [Trait(Category.AcceptanceType, Category.CheckIn)]
+ public void TestNewSubscription()
+ {
+ TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscription");
+ }
+
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateRenameSubscription()
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1 b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
index b29d58c7e596..e071b2295882 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
@@ -16,6 +16,22 @@
.SYNOPSIS
Create subscription
#>
+function Test-NewSubscription
+{
+ # $accounts = Get-AzEnrollmentAccount
+ $accounts = @(@{ ObjectId = "455fd0a7-b04e-4a92-9e1b-d0650c8ba276" })
+
+ # Verify the caller has at least one enrollment account.
+ Assert-True { $accounts.Count -gt 0 }
+
+ $myNewSubName = GetAssetName
+
+ $newSub = New-AzSubscription -EnrollmentAccountObjectId $accounts[0].ObjectId -Name $myNewSubName -OfferType MS-AZR-0017P
+
+ Assert-AreEqual $myNewSubName $newSub.Name
+ Assert-NotNull $newSub.SubscriptionId
+}
+
function Test-UpdateRenameSubscription
{
$subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
new file mode 100644
index 000000000000..0fa3b7613a15
--- /dev/null
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
@@ -0,0 +1,243 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Billing/enrollmentAccounts/455fd0a7-b04e-4a92-9e1b-d0650c8ba276/providers/Microsoft.Subscription/createSubscription?api-version=2019-10-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9lbnJvbGxtZW50QWNjb3VudHMvNDU1ZmQwYTctYjA0ZS00YTkyLTllMWItZDA2NTBjOGJhMjc2L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2NyZWF0ZVN1YnNjcmlwdGlvbj9hcGktdmVyc2lvbj0yMDE5LTEwLTAxLXByZXZpZXc=",
+ "RequestMethod": "POST",
+ "RequestBody": "{\r\n \"displayName\": \"ps821\",\r\n \"owners\": [],\r\n \"offerType\": \"MS-AZR-0017P\"\r\n}",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "00a2d30a-4e30-4463-8696-11317d788002"
+ ],
+ "Accept-Language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Content-Length": [
+ "79"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Location": [
+ "https://management.azure.com/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview"
+ ],
+ "Retry-After": [
+ "30"
+ ],
+ "x-ms-correlation-request-id": [
+ "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
+ ],
+ "request-id": [
+ "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-resource-requests": [
+ "499"
+ ],
+ "x-ms-request-id": [
+ "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200902T203027Z:5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Wed, 02 Sep 2020 20:30:27 GMT"
+ ],
+ "Content-Length": [
+ "2"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ]
+ },
+ "ResponseBody": "{}",
+ "StatusCode": 202
+ },
+ {
+ "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvTW1NMU9XWTVZVE10T1RSbE9DMDBZakkxTFRrNU16UXRaRFUyWm1FMU9XRmtPV016P2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "11999"
+ ],
+ "x-ms-correlation-request-id": [
+ "03fea370-3623-47aa-8809-0c635257ed6e"
+ ],
+ "request-id": [
+ "03fea370-3623-47aa-8809-0c635257ed6e"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-request-id": [
+ "03fea370-3623-47aa-8809-0c635257ed6e"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200902T203057Z:03fea370-3623-47aa-8809-0c635257ed6e"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Wed, 02 Sep 2020 20:30:56 GMT"
+ ],
+ "Content-Length": [
+ "74"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ]
+ },
+ "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/2c59f9a3-94e8-4b25-9934-d56fa59ad9c3\"\r\n}",
+ "StatusCode": 200
+ },
+ {
+ "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvTW1NMU9XWTVZVE10T1RSbE9DMDBZakkxTFRrNU16UXRaRFUyWm1FMU9XRmtPV016P2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "User-Agent": [
+ "FxVersion/4.6.29130.01",
+ "OSName/Windows",
+ "OSVersion/Microsoft.Windows.10.0.19041.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
+ ]
+ },
+ "ResponseHeaders": {
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Vary": [
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "11998"
+ ],
+ "x-ms-correlation-request-id": [
+ "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
+ ],
+ "request-id": [
+ "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
+ ],
+ "x-gsm": [
+ "1.0.0.0"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ],
+ "Server": [
+ "Microsoft-IIS/10.0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-request-id": [
+ "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
+ ],
+ "x-ms-routing-request-id": [
+ "WESTUS:20200902T203057Z:3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "Date": [
+ "Wed, 02 Sep 2020 20:30:57 GMT"
+ ],
+ "Content-Length": [
+ "74"
+ ],
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ]
+ },
+ "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/2c59f9a3-94e8-4b25-9934-d56fa59ad9c3\"\r\n}",
+ "StatusCode": 200
+ }
+ ],
+ "Names": {
+ "Test-NewSubscription": [
+ "ps821"
+ ]
+ },
+ "Variables": {
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
+ }
+}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/Subscription.Test.csproj b/src/Subscription/Subscription.Test/Subscription.Test.csproj
index 36ef0fcc029b..89fa3267df76 100644
--- a/src/Subscription/Subscription.Test/Subscription.Test.csproj
+++ b/src/Subscription/Subscription.Test/Subscription.Test.csproj
@@ -11,7 +11,7 @@
-
+
\ No newline at end of file
diff --git a/src/Subscription/Subscription.sln b/src/Subscription/Subscription.sln
index cd87447b71ba..ea105df69e05 100644
--- a/src/Subscription/Subscription.sln
+++ b/src/Subscription/Subscription.sln
@@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioTest.ResourceManage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriptionPreview", "SubscriptionPreview\SubscriptionPreview.csproj", "{BE89A8DC-5572-4607-9AAC-6C3AC3177D45}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -52,6 +54,10 @@ Global
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Subscription/Subscription/Az.Subscription.psd1 b/src/Subscription/Subscription/Az.Subscription.psd1
index 24f9a1bd37a9..e505f158df11 100644
--- a/src/Subscription/Subscription/Az.Subscription.psd1
+++ b/src/Subscription/Subscription/Az.Subscription.psd1
@@ -72,7 +72,7 @@ NestedModules = @('Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll')
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-CmdletsToExport = 'Update-AzSubscription','New-AzSubscriptionAlias','Get-AzSubscriptionAlias','Remove-AzSubscriptionAlias'
+CmdletsToExport = 'New-AzSubscription','Update-AzSubscription','New-AzSubscriptionAlias','Get-AzSubscriptionAlias','Remove-AzSubscriptionAlias'
# Variables to export from this module
# VariablesToExport = @()
diff --git a/src/Subscription/Subscription/ChangeLog.md b/src/Subscription/Subscription/ChangeLog.md
index 5c0f7028e04e..8401eefc1fb6 100644
--- a/src/Subscription/Subscription/ChangeLog.md
+++ b/src/Subscription/Subscription/ChangeLog.md
@@ -20,7 +20,7 @@
## Upcoming Release
## Version 0.7.4
-* Added new cmdlets `New-AzSubscriptionAlias`, deprecating cmdlet `New-AzSubscription`
+* Added new cmdlets `New-AzSubscriptionAlias`
## Version 0.7.3
* Added new cmdlet `Update-AzSubscription`
diff --git a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
new file mode 100644
index 000000000000..381feb52bdf3
--- /dev/null
+++ b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
@@ -0,0 +1,145 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Commands.Common.Authentication;
+using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.Commands.ResourceManager.Common;
+using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
+using Microsoft.Azure.Commands.Subscription.Models;
+using Microsoft.Azure.Graph.RBAC.Version1_6;
+using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
+using Microsoft.Azure.Graph.RBAC.Version1_6.Models;
+using Microsoft.Azure.Management.Subscription;
+using Microsoft.Azure.Management.Subscription.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Automation;
+using SubscriptionPreview;
+
+namespace Microsoft.Azure.Commands.Subscription.Cmdlets
+{
+ [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Subscription", SupportsShouldProcess = true), OutputType(typeof(PSAzureSubscription))]
+ public class NewAzureRmSubscription : AzureRmLongRunningCmdlet
+ {
+ private ActiveDirectoryClient _activeDirectoryClient;
+ private ISubscriptionClient _subscriptionClient;
+
+ public ActiveDirectoryClient ActiveDirectoryClient
+ {
+ get
+ {
+ if (_activeDirectoryClient == null)
+ {
+ _activeDirectoryClient = new ActiveDirectoryClient(DefaultContext);
+ }
+ return this._activeDirectoryClient;
+ }
+
+ set { this._activeDirectoryClient = value; }
+ }
+
+ ///
+ /// Gets or sets the subscription client.
+ ///
+ public ISubscriptionClient SubscriptionClient
+ {
+ get
+ {
+ return _subscriptionClient ??
+ (_subscriptionClient =
+ AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
+ AzureEnvironment.Endpoint.ResourceManager));
+ }
+ set { _subscriptionClient = value; }
+ }
+
+ [Parameter(Mandatory = true, HelpMessage = "Name of the enrollment account to use when creating the subscription.")]
+ public string EnrollmentAccountObjectId { get; set; }
+
+ [Parameter(Mandatory = false, Position = 0, HelpMessage = "Name of the subscription. When not specified, a name will be generated based on the specified offer type.")]
+ public string Name { get; set; }
+
+ [Parameter(Mandatory = true, HelpMessage = "Offer type of the subscription.")]
+ [PSArgumentCompleter("MS-AZR-0017P", "MS-AZR-0148P")]
+ public string OfferType { get; set; }
+
+ [Parameter(Mandatory = false, HelpMessage = "The user(s) or group object(s) id(s) to be granted Owner access to the subscription.")]
+ [Alias("OwnerId", "OwnerPrincipalId")]
+ public string[] OwnerObjectId { get; set; }
+
+ [Parameter(Mandatory = false, HelpMessage = "The user(s) to be granted Owner access to the subscription.")]
+ [Alias("OwnerEmail", "OwnerUserPrincipalName")]
+ public string[] OwnerSignInName { get; set; }
+
+ [Parameter(Mandatory = false, HelpMessage = "The app SPN(s) to be granted Owner access to the subscription.")]
+ [Alias("OwnerSPN", "OwnerServicePrincipalName")]
+ public string[] OwnerApplicationId { get; set; }
+
+ public override void ExecuteCmdlet()
+ {
+ if (this.ShouldProcess(target: this.Name, action: "Create subscription"))
+ {
+
+ var owners = this
+ .ResolveObjectIds(this.OwnerObjectId, this.OwnerApplicationId, this.OwnerSignInName);
+
+ // Create the subscription.
+ LegacySubscription legacySubscription = new LegacySubscription();
+
+ var result = legacySubscription.createSubscription(DefaultContext, this.EnrollmentAccountObjectId, this.Name, this.OfferType, owners);
+
+ result.SetTenant(DefaultContext.Tenant.Id);
+ WriteObject(new PSAzureSubscription(result));
+ }
+ }
+
+ private string[] ResolveObjectIds(string[] objectIds, string[] servicePrincipalNames, string[] userPrincipalNames)
+ {
+ var uniqueObjectIds = new HashSet(objectIds?.Select(id => Guid.Parse(id)) ?? new Guid[0]);
+
+ if (servicePrincipalNames != null)
+ {
+ foreach (string spn in servicePrincipalNames)
+ {
+ uniqueObjectIds.Add(ActiveDirectoryClient.GetObjectIdFromSPN(spn));
+ }
+ }
+
+ if (userPrincipalNames != null)
+ {
+ foreach (string upn in userPrincipalNames)
+ {
+ // TODO: Revert once available: uniqueObjectIds.Add(Guid.Parse(ActiveDirectoryClient.GetObjectIdFromUPN(upn)));
+ uniqueObjectIds.Add(Guid.Parse(GetObjectIdFromUPN(ActiveDirectoryClient, upn)));
+ }
+ }
+
+ return uniqueObjectIds.Select(id => id.ToString()).ToArray();
+ }
+
+ // Temporary until this code has moved into ActiveDirectoryClient.
+ private static string GetObjectIdFromUPN(ActiveDirectoryClient activeDirectoryClient, string upn)
+ {
+ var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.UserPrincipalName == upn);
+ var user = activeDirectoryClient.GraphClient.Users.List(odataQueryFilter.ToString()).SingleOrDefault();
+ if (user == null)
+ {
+ throw new InvalidOperationException(String.Format("User with UPN '{0}' does not exist.", upn));
+ }
+
+ return user.ObjectId;
+ }
+ }
+}
diff --git a/src/Subscription/Subscription/Subscription.csproj b/src/Subscription/Subscription/Subscription.csproj
index ed379c9cbbc0..faab11c39af8 100644
--- a/src/Subscription/Subscription/Subscription.csproj
+++ b/src/Subscription/Subscription/Subscription.csproj
@@ -14,4 +14,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Subscription/Subscription/help/Az.Subscription.md b/src/Subscription/Subscription/help/Az.Subscription.md
index 963656591a8d..860d4be13e94 100644
--- a/src/Subscription/Subscription/help/Az.Subscription.md
+++ b/src/Subscription/Subscription/help/Az.Subscription.md
@@ -11,6 +11,9 @@ Locale: en-US
The topics in this section document the Azure PowerShell cmdlets for Azure Subscription in the Azure Resource Manager (ARM) framework. The cmdlets exist in the Microsoft.Azure.Commands.Subscription namespace.
## Az.Subscription Cmdlets
+### [New-AzSubscription](New-AzSubscription.md)
+Creates new Subscription
+
### [Update-AzSubscription](Update-AzSubscription.md)
Updates an Azure Subscription
diff --git a/src/Subscription/Subscription/help/New-AzSubscription.md b/src/Subscription/Subscription/help/New-AzSubscription.md
new file mode 100644
index 000000000000..d047e41a8123
--- /dev/null
+++ b/src/Subscription/Subscription/help/New-AzSubscription.md
@@ -0,0 +1,203 @@
+---
+external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
+Module Name: Az.Subscription
+online version: https://docs.microsoft.com/en-us/powershell/module/az.subscription/new-azsubscription
+schema: 2.0.0
+---
+
+# New-AzSubscription
+
+## SYNOPSIS
+Creates an Azure subscription.
+
+## SYNTAX
+
+```
+New-AzSubscription -EnrollmentAccountObjectId [[-Name] ] -OfferType
+ [-OwnerObjectId ] [-OwnerSignInName ] [-OwnerApplicationId ] [-AsJob]
+ [-DefaultProfile ] [-WhatIf] [-Confirm] []
+```
+
+## DESCRIPTION
+The **New-AzSubscription** cmdlet creates an Azure subscription.
+
+## EXAMPLES
+
+### Example 1
+```
+PS C:\> New-AzSubscription -Name "My Subscription" -EnrollmentAccountObjectId ((Get-AzEnrollmentAccount)[0].ObjectId) -OfferType MS-AZR-0017P
+
+Name : My Subscription
+Id : 86869d42-1782-4337-98b0-c905fb937d46
+TenantId : a5dcb057-fd83-4384-9d49-5198004d33a5
+State : Enabled
+```
+
+Creates an Azure subscription under the specified enrollment account with the specified offer type.
+
+## PARAMETERS
+
+### -AsJob
+Run cmdlet in the background
+
+```yaml
+Type: System.Management.Automation.SwitchParameter
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -DefaultProfile
+The credentials, account, tenant, and subscription used for communication with Azure.
+
+```yaml
+Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
+Parameter Sets: (All)
+Aliases: AzContext, AzureRmContext, AzureCredential
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -EnrollmentAccountObjectId
+Name of the enrollment account to use when creating the subscription.
+
+```yaml
+Type: System.String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Name
+The name of the subscription to create.
+
+```yaml
+Type: System.String
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: 0
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -OfferType
+The type of offer to use when creating the subscription.
+
+```yaml
+Type: System.String
+Parameter Sets: (All)
+Aliases:
+
+Required: True
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -OwnerApplicationId
+The app SPN(s) to be granted Owner access to the subscription.
+
+```yaml
+Type: System.String[]
+Parameter Sets: (All)
+Aliases: OwnerSPN, OwnerServicePrincipalName
+
+Required: False
+Position: Named
+Default value: Name
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -OwnerObjectId
+The user(s) or group object(s) id(s) to be granted Owner access to the subscription.
+
+```yaml
+Type: System.String[]
+Parameter Sets: (All)
+Aliases: OwnerId, OwnerPrincipalId
+
+Required: False
+Position: Named
+Default value: Name
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -OwnerSignInName
+The user(s) to be granted Owner access to the subscription.
+
+```yaml
+Type: System.String[]
+Parameter Sets: (All)
+Aliases: OwnerEmail, OwnerUserPrincipalName
+
+Required: False
+Position: Named
+Default value: Name
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -Confirm
+Prompts you for confirmation before running the cmdlet.
+
+```yaml
+Type: System.Management.Automation.SwitchParameter
+Parameter Sets: (All)
+Aliases: cf
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### -WhatIf
+Shows what would happen if the cmdlet runs. The cmdlet is not run.
+
+```yaml
+Type: System.Management.Automation.SwitchParameter
+Parameter Sets: (All)
+Aliases: wi
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
+### CommonParameters
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
+
+## INPUTS
+
+### None
+
+## OUTPUTS
+
+### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
+
+## NOTES
+
+## RELATED LINKS
diff --git a/src/Subscription/SubscriptionPreview/LegacySubscription.cs b/src/Subscription/SubscriptionPreview/LegacySubscription.cs
new file mode 100644
index 000000000000..a5e2f6cc867e
--- /dev/null
+++ b/src/Subscription/SubscriptionPreview/LegacySubscription.cs
@@ -0,0 +1,56 @@
+// ----------------------------------------------------------------------------------
+//
+// Copyright Microsoft Corporation
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------------
+
+using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
+using Microsoft.Azure.Management.Subscription;
+using Microsoft.Azure.Management.Subscription.Models;
+using System.Linq;
+
+namespace SubscriptionPreview
+{
+ public class LegacySubscription
+ {
+ private ISubscriptionClient _subscriptionClient;
+
+ public AzureSubscription createSubscription(IAzureContext DefaultContext, string enrollmentAccountObjectId, string name, string offerType, string[] ownerList)
+ {
+ _subscriptionClient =
+ Microsoft.Azure.Commands.Common.Authentication.AzureSession.Instance.ClientFactory
+ .CreateArmClient(DefaultContext, AzureEnvironment.Endpoint.ResourceManager);
+
+ SubscriptionCreationResult result = new SubscriptionCreationResult();
+
+ var owners = ownerList.Select(id => new AdPrincipal() { ObjectId = id }).ToArray();
+
+ result = _subscriptionClient.Subscription.CreateSubscriptionInEnrollmentAccount(
+ enrollmentAccountObjectId,new SubscriptionCreationParameters()
+ {
+ DisplayName = name,
+ OfferType = offerType,
+ Owners = owners
+ });
+
+ var createdSubscription = new AzureSubscription()
+ {
+ // SubscriptionLink format is: "/subscriptions/{subscriptionid}"
+ Id = result.SubscriptionLink.Split('/')[2],
+ Name = name,
+ // By definition, a new subscription is always in the enabled state.
+ State = "Enabled",
+ };
+
+ return createdSubscription;
+ }
+ }
+}
diff --git a/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj b/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
new file mode 100644
index 000000000000..02d2ce9c0a64
--- /dev/null
+++ b/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
@@ -0,0 +1,15 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
+
From 5bbb332d1e33303c6244b9783d8b4108ee8bc8ed Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Thu, 8 Oct 2020 12:10:04 -0700
Subject: [PATCH 3/9] Minor changes
---
.../ScenarioTests/SubscriptionTests.cs | 7 -
.../ScenarioTests/SubscriptionTests.ps1 | 16 --
.../TestNewSubscription.json | 243 ------------------
.../Subscription.Test.csproj | 2 +-
src/Subscription/Subscription.sln | 6 -
.../Subscription/Az.Subscription.psd1 | 2 +-
src/Subscription/Subscription/ChangeLog.md | 2 +-
.../Cmdlets/NewAzureRmSubscription.cs | 145 -----------
.../AzureRmSubscriptionStartup.ps1 | 12 +-
.../Subscription/Subscription.csproj | 4 -
.../Subscription/help/Az.Subscription.md | 3 -
.../Subscription/help/New-AzSubscription.md | 203 ---------------
12 files changed, 4 insertions(+), 641 deletions(-)
delete mode 100644 src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
delete mode 100644 src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
delete mode 100644 src/Subscription/Subscription/help/New-AzSubscription.md
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
index d9401aee96b6..73921cd24bf1 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.cs
@@ -35,13 +35,6 @@ public SubscriptionTests(Xunit.Abstractions.ITestOutputHelper output)
TestExecutionHelpers.SetUpSessionAndProfile();
}
- [Fact]
- [Trait(Category.AcceptanceType, Category.CheckIn)]
- public void TestNewSubscription()
- {
- TestController.NewInstance.RunPowerShellTest(_logger, "Test-NewSubscription");
- }
-
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateRenameSubscription()
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1 b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
index e071b2295882..b29d58c7e596 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
@@ -16,22 +16,6 @@
.SYNOPSIS
Create subscription
#>
-function Test-NewSubscription
-{
- # $accounts = Get-AzEnrollmentAccount
- $accounts = @(@{ ObjectId = "455fd0a7-b04e-4a92-9e1b-d0650c8ba276" })
-
- # Verify the caller has at least one enrollment account.
- Assert-True { $accounts.Count -gt 0 }
-
- $myNewSubName = GetAssetName
-
- $newSub = New-AzSubscription -EnrollmentAccountObjectId $accounts[0].ObjectId -Name $myNewSubName -OfferType MS-AZR-0017P
-
- Assert-AreEqual $myNewSubName $newSub.Name
- Assert-NotNull $newSub.SubscriptionId
-}
-
function Test-UpdateRenameSubscription
{
$subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
deleted file mode 100644
index 0fa3b7613a15..000000000000
--- a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestNewSubscription.json
+++ /dev/null
@@ -1,243 +0,0 @@
-{
- "Entries": [
- {
- "RequestUri": "/providers/Microsoft.Billing/enrollmentAccounts/455fd0a7-b04e-4a92-9e1b-d0650c8ba276/providers/Microsoft.Subscription/createSubscription?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuQmlsbGluZy9lbnJvbGxtZW50QWNjb3VudHMvNDU1ZmQwYTctYjA0ZS00YTkyLTllMWItZDA2NTBjOGJhMjc2L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2NyZWF0ZVN1YnNjcmlwdGlvbj9hcGktdmVyc2lvbj0yMDE5LTEwLTAxLXByZXZpZXc=",
- "RequestMethod": "POST",
- "RequestBody": "{\r\n \"displayName\": \"ps821\",\r\n \"owners\": [],\r\n \"offerType\": \"MS-AZR-0017P\"\r\n}",
- "RequestHeaders": {
- "x-ms-client-request-id": [
- "00a2d30a-4e30-4463-8696-11317d788002"
- ],
- "Accept-Language": [
- "en-US"
- ],
- "User-Agent": [
- "FxVersion/4.6.29130.01",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.19041.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Content-Length": [
- "79"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Location": [
- "https://management.azure.com/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview"
- ],
- "Retry-After": [
- "30"
- ],
- "x-ms-correlation-request-id": [
- "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
- ],
- "request-id": [
- "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-ratelimit-remaining-tenant-resource-requests": [
- "499"
- ],
- "x-ms-request-id": [
- "5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200902T203027Z:5b0273b2-83ff-4c4e-9cd2-89b357b832c8"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Wed, 02 Sep 2020 20:30:27 GMT"
- ],
- "Content-Length": [
- "2"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{}",
- "StatusCode": 202
- },
- {
- "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvTW1NMU9XWTVZVE10T1RSbE9DMDBZakkxTFRrNU16UXRaRFUyWm1FMU9XRmtPV016P2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
- "RequestMethod": "GET",
- "RequestBody": "",
- "RequestHeaders": {
- "User-Agent": [
- "FxVersion/4.6.29130.01",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.19041.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Vary": [
- "Accept-Encoding"
- ],
- "x-ms-ratelimit-remaining-tenant-reads": [
- "11999"
- ],
- "x-ms-correlation-request-id": [
- "03fea370-3623-47aa-8809-0c635257ed6e"
- ],
- "request-id": [
- "03fea370-3623-47aa-8809-0c635257ed6e"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-request-id": [
- "03fea370-3623-47aa-8809-0c635257ed6e"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200902T203057Z:03fea370-3623-47aa-8809-0c635257ed6e"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Wed, 02 Sep 2020 20:30:56 GMT"
- ],
- "Content-Length": [
- "74"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/2c59f9a3-94e8-4b25-9934-d56fa59ad9c3\"\r\n}",
- "StatusCode": 200
- },
- {
- "RequestUri": "/providers/Microsoft.Subscription/subscriptionOperations/MmM1OWY5YTMtOTRlOC00YjI1LTk5MzQtZDU2ZmE1OWFkOWMz?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3N1YnNjcmlwdGlvbk9wZXJhdGlvbnMvTW1NMU9XWTVZVE10T1RSbE9DMDBZakkxTFRrNU16UXRaRFUyWm1FMU9XRmtPV016P2FwaS12ZXJzaW9uPTIwMTktMTAtMDEtcHJldmlldw==",
- "RequestMethod": "GET",
- "RequestBody": "",
- "RequestHeaders": {
- "User-Agent": [
- "FxVersion/4.6.29130.01",
- "OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.19041.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
- ]
- },
- "ResponseHeaders": {
- "Cache-Control": [
- "no-cache"
- ],
- "Pragma": [
- "no-cache"
- ],
- "Vary": [
- "Accept-Encoding"
- ],
- "x-ms-ratelimit-remaining-tenant-reads": [
- "11998"
- ],
- "x-ms-correlation-request-id": [
- "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
- ],
- "request-id": [
- "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
- ],
- "x-gsm": [
- "1.0.0.0"
- ],
- "X-Content-Type-Options": [
- "nosniff"
- ],
- "Server": [
- "Microsoft-IIS/10.0"
- ],
- "X-AspNet-Version": [
- "4.0.30319"
- ],
- "X-Powered-By": [
- "ASP.NET"
- ],
- "x-ms-request-id": [
- "3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
- ],
- "x-ms-routing-request-id": [
- "WESTUS:20200902T203057Z:3dd59d45-5300-4ed3-b0a5-c1ccaf338c99"
- ],
- "Strict-Transport-Security": [
- "max-age=31536000; includeSubDomains"
- ],
- "Date": [
- "Wed, 02 Sep 2020 20:30:57 GMT"
- ],
- "Content-Length": [
- "74"
- ],
- "Content-Type": [
- "application/json; charset=utf-8"
- ],
- "Expires": [
- "-1"
- ]
- },
- "ResponseBody": "{\r\n \"subscriptionLink\": \"/subscriptions/2c59f9a3-94e8-4b25-9934-d56fa59ad9c3\"\r\n}",
- "StatusCode": 200
- }
- ],
- "Names": {
- "Test-NewSubscription": [
- "ps821"
- ]
- },
- "Variables": {
- "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
- }
-}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/Subscription.Test.csproj b/src/Subscription/Subscription.Test/Subscription.Test.csproj
index 89fa3267df76..36ef0fcc029b 100644
--- a/src/Subscription/Subscription.Test/Subscription.Test.csproj
+++ b/src/Subscription/Subscription.Test/Subscription.Test.csproj
@@ -11,7 +11,7 @@
-
+
\ No newline at end of file
diff --git a/src/Subscription/Subscription.sln b/src/Subscription/Subscription.sln
index ea105df69e05..cd87447b71ba 100644
--- a/src/Subscription/Subscription.sln
+++ b/src/Subscription/Subscription.sln
@@ -18,8 +18,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScenarioTest.ResourceManage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubscriptionPreview", "SubscriptionPreview\SubscriptionPreview.csproj", "{BE89A8DC-5572-4607-9AAC-6C3AC3177D45}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -54,10 +52,6 @@ Global
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC80A1D0-FFA4-43D9-AA74-799F5CB54B58}.Release|Any CPU.Build.0 = Release|Any CPU
- {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BE89A8DC-5572-4607-9AAC-6C3AC3177D45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/Subscription/Subscription/Az.Subscription.psd1 b/src/Subscription/Subscription/Az.Subscription.psd1
index e505f158df11..24f9a1bd37a9 100644
--- a/src/Subscription/Subscription/Az.Subscription.psd1
+++ b/src/Subscription/Subscription/Az.Subscription.psd1
@@ -72,7 +72,7 @@ NestedModules = @('Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll')
FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
-CmdletsToExport = 'New-AzSubscription','Update-AzSubscription','New-AzSubscriptionAlias','Get-AzSubscriptionAlias','Remove-AzSubscriptionAlias'
+CmdletsToExport = 'Update-AzSubscription','New-AzSubscriptionAlias','Get-AzSubscriptionAlias','Remove-AzSubscriptionAlias'
# Variables to export from this module
# VariablesToExport = @()
diff --git a/src/Subscription/Subscription/ChangeLog.md b/src/Subscription/Subscription/ChangeLog.md
index 8401eefc1fb6..bb8e5152a8de 100644
--- a/src/Subscription/Subscription/ChangeLog.md
+++ b/src/Subscription/Subscription/ChangeLog.md
@@ -20,7 +20,7 @@
## Upcoming Release
## Version 0.7.4
-* Added new cmdlets `New-AzSubscriptionAlias`
+* Added new cmdlets `New-AzSubscriptionAlias` and Removed cmdlet `New-AzSubscription`
## Version 0.7.3
* Added new cmdlet `Update-AzSubscription`
diff --git a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
deleted file mode 100644
index 381feb52bdf3..000000000000
--- a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscription.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-using Microsoft.Azure.Commands.Common.Authentication;
-using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
-using Microsoft.Azure.Commands.ResourceManager.Common;
-using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
-using Microsoft.Azure.Commands.Subscription.Models;
-using Microsoft.Azure.Graph.RBAC.Version1_6;
-using Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory;
-using Microsoft.Azure.Graph.RBAC.Version1_6.Models;
-using Microsoft.Azure.Management.Subscription;
-using Microsoft.Azure.Management.Subscription.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Management.Automation;
-using SubscriptionPreview;
-
-namespace Microsoft.Azure.Commands.Subscription.Cmdlets
-{
- [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Subscription", SupportsShouldProcess = true), OutputType(typeof(PSAzureSubscription))]
- public class NewAzureRmSubscription : AzureRmLongRunningCmdlet
- {
- private ActiveDirectoryClient _activeDirectoryClient;
- private ISubscriptionClient _subscriptionClient;
-
- public ActiveDirectoryClient ActiveDirectoryClient
- {
- get
- {
- if (_activeDirectoryClient == null)
- {
- _activeDirectoryClient = new ActiveDirectoryClient(DefaultContext);
- }
- return this._activeDirectoryClient;
- }
-
- set { this._activeDirectoryClient = value; }
- }
-
- ///
- /// Gets or sets the subscription client.
- ///
- public ISubscriptionClient SubscriptionClient
- {
- get
- {
- return _subscriptionClient ??
- (_subscriptionClient =
- AzureSession.Instance.ClientFactory.CreateArmClient(DefaultContext,
- AzureEnvironment.Endpoint.ResourceManager));
- }
- set { _subscriptionClient = value; }
- }
-
- [Parameter(Mandatory = true, HelpMessage = "Name of the enrollment account to use when creating the subscription.")]
- public string EnrollmentAccountObjectId { get; set; }
-
- [Parameter(Mandatory = false, Position = 0, HelpMessage = "Name of the subscription. When not specified, a name will be generated based on the specified offer type.")]
- public string Name { get; set; }
-
- [Parameter(Mandatory = true, HelpMessage = "Offer type of the subscription.")]
- [PSArgumentCompleter("MS-AZR-0017P", "MS-AZR-0148P")]
- public string OfferType { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The user(s) or group object(s) id(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerId", "OwnerPrincipalId")]
- public string[] OwnerObjectId { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The user(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerEmail", "OwnerUserPrincipalName")]
- public string[] OwnerSignInName { get; set; }
-
- [Parameter(Mandatory = false, HelpMessage = "The app SPN(s) to be granted Owner access to the subscription.")]
- [Alias("OwnerSPN", "OwnerServicePrincipalName")]
- public string[] OwnerApplicationId { get; set; }
-
- public override void ExecuteCmdlet()
- {
- if (this.ShouldProcess(target: this.Name, action: "Create subscription"))
- {
-
- var owners = this
- .ResolveObjectIds(this.OwnerObjectId, this.OwnerApplicationId, this.OwnerSignInName);
-
- // Create the subscription.
- LegacySubscription legacySubscription = new LegacySubscription();
-
- var result = legacySubscription.createSubscription(DefaultContext, this.EnrollmentAccountObjectId, this.Name, this.OfferType, owners);
-
- result.SetTenant(DefaultContext.Tenant.Id);
- WriteObject(new PSAzureSubscription(result));
- }
- }
-
- private string[] ResolveObjectIds(string[] objectIds, string[] servicePrincipalNames, string[] userPrincipalNames)
- {
- var uniqueObjectIds = new HashSet(objectIds?.Select(id => Guid.Parse(id)) ?? new Guid[0]);
-
- if (servicePrincipalNames != null)
- {
- foreach (string spn in servicePrincipalNames)
- {
- uniqueObjectIds.Add(ActiveDirectoryClient.GetObjectIdFromSPN(spn));
- }
- }
-
- if (userPrincipalNames != null)
- {
- foreach (string upn in userPrincipalNames)
- {
- // TODO: Revert once available: uniqueObjectIds.Add(Guid.Parse(ActiveDirectoryClient.GetObjectIdFromUPN(upn)));
- uniqueObjectIds.Add(Guid.Parse(GetObjectIdFromUPN(ActiveDirectoryClient, upn)));
- }
- }
-
- return uniqueObjectIds.Select(id => id.ToString()).ToArray();
- }
-
- // Temporary until this code has moved into ActiveDirectoryClient.
- private static string GetObjectIdFromUPN(ActiveDirectoryClient activeDirectoryClient, string upn)
- {
- var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.UserPrincipalName == upn);
- var user = activeDirectoryClient.GraphClient.Users.List(odataQueryFilter.ToString()).SingleOrDefault();
- if (user == null)
- {
- throw new InvalidOperationException(String.Format("User with UPN '{0}' does not exist.", upn));
- }
-
- return user.ObjectId;
- }
- }
-}
diff --git a/src/Subscription/Subscription/StartupScripts/AzureRmSubscriptionStartup.ps1 b/src/Subscription/Subscription/StartupScripts/AzureRmSubscriptionStartup.ps1
index bb1fd42b6502..cbe8b0f44e11 100644
--- a/src/Subscription/Subscription/StartupScripts/AzureRmSubscriptionStartup.ps1
+++ b/src/Subscription/Subscription/StartupScripts/AzureRmSubscriptionStartup.ps1
@@ -1,14 +1,4 @@
-Register-ArgumentCompleter -CommandName New-AzSubscription -ParameterName OfferType -ScriptBlock {
- param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
-
- $values = "MS-AZR-0017P", "MS-AZR-0148P"
- $values |
- ForEach-Object {
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
- }
-}
-
-Register-ArgumentCompleter -CommandName Update-AzSubscription -ParameterName Action -ScriptBlock {
+Register-ArgumentCompleter -CommandName Update-AzSubscription -ParameterName Action -ScriptBlock {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$values = "Cancel", "Rename", "Enable"
diff --git a/src/Subscription/Subscription/Subscription.csproj b/src/Subscription/Subscription/Subscription.csproj
index faab11c39af8..ed379c9cbbc0 100644
--- a/src/Subscription/Subscription/Subscription.csproj
+++ b/src/Subscription/Subscription/Subscription.csproj
@@ -14,8 +14,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/src/Subscription/Subscription/help/Az.Subscription.md b/src/Subscription/Subscription/help/Az.Subscription.md
index 860d4be13e94..963656591a8d 100644
--- a/src/Subscription/Subscription/help/Az.Subscription.md
+++ b/src/Subscription/Subscription/help/Az.Subscription.md
@@ -11,9 +11,6 @@ Locale: en-US
The topics in this section document the Azure PowerShell cmdlets for Azure Subscription in the Azure Resource Manager (ARM) framework. The cmdlets exist in the Microsoft.Azure.Commands.Subscription namespace.
## Az.Subscription Cmdlets
-### [New-AzSubscription](New-AzSubscription.md)
-Creates new Subscription
-
### [Update-AzSubscription](Update-AzSubscription.md)
Updates an Azure Subscription
diff --git a/src/Subscription/Subscription/help/New-AzSubscription.md b/src/Subscription/Subscription/help/New-AzSubscription.md
deleted file mode 100644
index d047e41a8123..000000000000
--- a/src/Subscription/Subscription/help/New-AzSubscription.md
+++ /dev/null
@@ -1,203 +0,0 @@
----
-external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
-Module Name: Az.Subscription
-online version: https://docs.microsoft.com/en-us/powershell/module/az.subscription/new-azsubscription
-schema: 2.0.0
----
-
-# New-AzSubscription
-
-## SYNOPSIS
-Creates an Azure subscription.
-
-## SYNTAX
-
-```
-New-AzSubscription -EnrollmentAccountObjectId [[-Name] ] -OfferType
- [-OwnerObjectId ] [-OwnerSignInName ] [-OwnerApplicationId ] [-AsJob]
- [-DefaultProfile ] [-WhatIf] [-Confirm] []
-```
-
-## DESCRIPTION
-The **New-AzSubscription** cmdlet creates an Azure subscription.
-
-## EXAMPLES
-
-### Example 1
-```
-PS C:\> New-AzSubscription -Name "My Subscription" -EnrollmentAccountObjectId ((Get-AzEnrollmentAccount)[0].ObjectId) -OfferType MS-AZR-0017P
-
-Name : My Subscription
-Id : 86869d42-1782-4337-98b0-c905fb937d46
-TenantId : a5dcb057-fd83-4384-9d49-5198004d33a5
-State : Enabled
-```
-
-Creates an Azure subscription under the specified enrollment account with the specified offer type.
-
-## PARAMETERS
-
-### -AsJob
-Run cmdlet in the background
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases:
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -DefaultProfile
-The credentials, account, tenant, and subscription used for communication with Azure.
-
-```yaml
-Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
-Parameter Sets: (All)
-Aliases: AzContext, AzureRmContext, AzureCredential
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -EnrollmentAccountObjectId
-Name of the enrollment account to use when creating the subscription.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: True
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -Name
-The name of the subscription to create.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: False
-Position: 0
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OfferType
-The type of offer to use when creating the subscription.
-
-```yaml
-Type: System.String
-Parameter Sets: (All)
-Aliases:
-
-Required: True
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerApplicationId
-The app SPN(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerSPN, OwnerServicePrincipalName
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerObjectId
-The user(s) or group object(s) id(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerId, OwnerPrincipalId
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -OwnerSignInName
-The user(s) to be granted Owner access to the subscription.
-
-```yaml
-Type: System.String[]
-Parameter Sets: (All)
-Aliases: OwnerEmail, OwnerUserPrincipalName
-
-Required: False
-Position: Named
-Default value: Name
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -Confirm
-Prompts you for confirmation before running the cmdlet.
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases: cf
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### -WhatIf
-Shows what would happen if the cmdlet runs. The cmdlet is not run.
-
-```yaml
-Type: System.Management.Automation.SwitchParameter
-Parameter Sets: (All)
-Aliases: wi
-
-Required: False
-Position: Named
-Default value: None
-Accept pipeline input: False
-Accept wildcard characters: False
-```
-
-### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
-
-## INPUTS
-
-### None
-
-## OUTPUTS
-
-### Microsoft.Azure.Commands.Subscription.Models.PSAzureSubscription
-
-## NOTES
-
-## RELATED LINKS
From d54496d36358aa4cee8ea2cd522193beb1f111bc Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Thu, 8 Oct 2020 18:11:34 -0700
Subject: [PATCH 4/9] Removing files
---
.../SubscriptionPreview/LegacySubscription.cs | 56 -------------------
.../SubscriptionPreview.csproj | 15 -----
2 files changed, 71 deletions(-)
delete mode 100644 src/Subscription/SubscriptionPreview/LegacySubscription.cs
delete mode 100644 src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
diff --git a/src/Subscription/SubscriptionPreview/LegacySubscription.cs b/src/Subscription/SubscriptionPreview/LegacySubscription.cs
deleted file mode 100644
index a5e2f6cc867e..000000000000
--- a/src/Subscription/SubscriptionPreview/LegacySubscription.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// ----------------------------------------------------------------------------------
-//
-// Copyright Microsoft Corporation
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ----------------------------------------------------------------------------------
-
-using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
-using Microsoft.Azure.Management.Subscription;
-using Microsoft.Azure.Management.Subscription.Models;
-using System.Linq;
-
-namespace SubscriptionPreview
-{
- public class LegacySubscription
- {
- private ISubscriptionClient _subscriptionClient;
-
- public AzureSubscription createSubscription(IAzureContext DefaultContext, string enrollmentAccountObjectId, string name, string offerType, string[] ownerList)
- {
- _subscriptionClient =
- Microsoft.Azure.Commands.Common.Authentication.AzureSession.Instance.ClientFactory
- .CreateArmClient(DefaultContext, AzureEnvironment.Endpoint.ResourceManager);
-
- SubscriptionCreationResult result = new SubscriptionCreationResult();
-
- var owners = ownerList.Select(id => new AdPrincipal() { ObjectId = id }).ToArray();
-
- result = _subscriptionClient.Subscription.CreateSubscriptionInEnrollmentAccount(
- enrollmentAccountObjectId,new SubscriptionCreationParameters()
- {
- DisplayName = name,
- OfferType = offerType,
- Owners = owners
- });
-
- var createdSubscription = new AzureSubscription()
- {
- // SubscriptionLink format is: "/subscriptions/{subscriptionid}"
- Id = result.SubscriptionLink.Split('/')[2],
- Name = name,
- // By definition, a new subscription is always in the enabled state.
- State = "Enabled",
- };
-
- return createdSubscription;
- }
- }
-}
diff --git a/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj b/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
deleted file mode 100644
index 02d2ce9c0a64..000000000000
--- a/src/Subscription/SubscriptionPreview/SubscriptionPreview.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- netstandard2.0
-
-
-
-
-
-
-
-
-
-
-
From cd04b9d282a5f6689c3732531fe287346bcfb0fd Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Fri, 9 Oct 2020 10:40:21 -0700
Subject: [PATCH 5/9] Removing redundant code
---
.../Cmdlets/GetAzureRmSubscriptionAlias.cs | 1 -
.../Cmdlets/NewAzureRmSubscriptionAlias.cs | 20 +++++++++----------
.../Cmdlets/RemoveAzureRmSubscriptionAlias.cs | 2 --
.../help/New-AzSubscriptionAlias.md | 2 +-
4 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
index 5cae530d2178..d3a780081ea5 100644
--- a/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
+++ b/src/Subscription/Subscription/Cmdlets/GetAzureRmSubscriptionAlias.cs
@@ -16,7 +16,6 @@
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.ResourceManager.Common;
-using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Commands.Subscription.Models;
using Microsoft.Azure.Management.Subscription;
using Microsoft.Azure.Management.Subscription.Models;
diff --git a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
index 790bb4bb89e9..85bbe4a3f599 100644
--- a/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
+++ b/src/Subscription/Subscription/Cmdlets/NewAzureRmSubscriptionAlias.cs
@@ -47,16 +47,19 @@ public ISubscriptionClient SubscriptionClient
[Parameter(Mandatory = true, HelpMessage = "Alias for the subscription")]
public string AliasName { get; set; }
- [Parameter(Mandatory = true, HelpMessage = "Billing Scope")]
+ [Parameter(Mandatory = false, HelpMessage = "Billing Scope")]
public string BillingScope { get; set; }
- [Parameter(Mandatory = true, HelpMessage = "Type of Workload")]
+ [Parameter(Mandatory = false, HelpMessage = "Type of Workload")]
[PSArgumentCompleter("Production", "DevTest")]
public string Workload { get; set; }
- [Parameter(Mandatory = true, HelpMessage = "Name of the subscription")]
+ [Parameter(Mandatory = false, HelpMessage = "Name of the subscription")]
public string SubscriptionName { get; set; }
+ [Parameter(Mandatory = false, HelpMessage = "Reseller Id")]
+ public string ResellerId { get; set; }
+
[Parameter(Mandatory = false, HelpMessage = "Existing Subscription Id")]
public string SubscriptionId { get; set; }
@@ -75,17 +78,12 @@ public override void ExecuteCmdlet()
BillingScope = BillingScope,
Workload = Workload,
DisplayName = SubscriptionName,
- SubscriptionId = SubscriptionId
+ SubscriptionId = SubscriptionId,
+ ResellerId = ResellerId
}
});
-
- // Write output.
- var createdSubscription = new AzureSubscription()
- {
- Id = result.Properties.SubscriptionId
- };
- WriteObject(new PSAzureSubscription(createdSubscription));
+ WriteObject(result);
}
}
}
diff --git a/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs b/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
index 63f9dfea73ed..12fb15739bfe 100644
--- a/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
+++ b/src/Subscription/Subscription/Cmdlets/RemoveAzureRmSubscriptionAlias.cs
@@ -16,10 +16,8 @@
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.ResourceManager.Common;
-using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Commands.Subscription.Models;
using Microsoft.Azure.Management.Subscription;
-using Microsoft.Azure.Management.Subscription.Models;
namespace Microsoft.Azure.Commands.Subscription.Cmdlets
{
diff --git a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
index 31504c1e67ea..cdd94409b885 100644
--- a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
@@ -70,7 +70,7 @@ Type: String
Parameter Sets: (All)
Aliases:
-Required: True
+Required: False
Position: Named
Default value: None
Accept pipeline input: False
From 1840355787e1565aad31f4f3db8aa727fc14afc4 Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Fri, 9 Oct 2020 10:52:34 -0700
Subject: [PATCH 6/9] Updated help
---
src/Subscription/Subscription/ChangeLog.md | 2 -
.../Subscription/help/Az.Subscription.md | 14 +++---
.../help/Get-AzSubscriptionAlias.md | 10 ++---
.../help/New-AzSubscriptionAlias.md | 43 +++++++++++++------
.../help/Remove-AzSubscriptionAlias.md | 10 ++---
5 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/src/Subscription/Subscription/ChangeLog.md b/src/Subscription/Subscription/ChangeLog.md
index bb8e5152a8de..58518b9c5e69 100644
--- a/src/Subscription/Subscription/ChangeLog.md
+++ b/src/Subscription/Subscription/ChangeLog.md
@@ -18,8 +18,6 @@
- Additional information about change #1
-->
## Upcoming Release
-
-## Version 0.7.4
* Added new cmdlets `New-AzSubscriptionAlias` and Removed cmdlet `New-AzSubscription`
## Version 0.7.3
diff --git a/src/Subscription/Subscription/help/Az.Subscription.md b/src/Subscription/Subscription/help/Az.Subscription.md
index 963656591a8d..3f6fc48e889b 100644
--- a/src/Subscription/Subscription/help/Az.Subscription.md
+++ b/src/Subscription/Subscription/help/Az.Subscription.md
@@ -11,15 +11,15 @@ Locale: en-US
The topics in this section document the Azure PowerShell cmdlets for Azure Subscription in the Azure Resource Manager (ARM) framework. The cmdlets exist in the Microsoft.Azure.Commands.Subscription namespace.
## Az.Subscription Cmdlets
-### [Update-AzSubscription](Update-AzSubscription.md)
-Updates an Azure Subscription
-
-### [New-AzSubscriptionAlias](New-AzSubscriptionAlias.md)
-Creates new Alias and Subscription
-
### [Get-AzSubscriptionAlias](Get-AzSubscriptionAlias.md)
Gets subscription alias details
+### [New-AzSubscriptionAlias](New-AzSubscriptionAlias.md)
+Creates new alias and subscription
+
### [Remove-AzSubscriptionAlias](Remove-AzSubscriptionAlias.md)
-Remove subscription alias
+Deletes the subscription alias
+
+### [Update-AzSubscription](Update-AzSubscription.md)
+Updates an Azure Subscription
diff --git a/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
index 227d5f53db4a..72ec929f6156 100644
--- a/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
@@ -35,7 +35,7 @@ Gets subscription alias details
Alias for the subscription
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
@@ -50,7 +50,7 @@ Accept wildcard characters: False
Run cmdlet in the background
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
@@ -65,7 +65,7 @@ Accept wildcard characters: False
The credentials, account, tenant, and subscription used for communication with Azure.
```yaml
-Type: IAzureContextContainer
+Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential
@@ -80,7 +80,7 @@ Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
@@ -96,7 +96,7 @@ Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
diff --git a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
index cdd94409b885..1f2c7e087ff0 100644
--- a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
@@ -13,9 +13,9 @@ Creates new alias and subscription
## SYNTAX
```
-New-AzSubscriptionAlias -AliasName -BillingScope -Workload
- -SubscriptionName [-SubscriptionId ] [-AsJob] [-DefaultProfile ]
- [-WhatIf] [-Confirm] []
+New-AzSubscriptionAlias -AliasName [-BillingScope ] [-Workload ]
+ [-SubscriptionName ] [-ResellerId ] [-SubscriptionId ] [-AsJob]
+ [-DefaultProfile ] [-WhatIf] [-Confirm] []
```
## DESCRIPTION
@@ -36,7 +36,7 @@ Creates new alias and subscription
Alias for the subscription
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
@@ -51,7 +51,7 @@ Accept wildcard characters: False
Run cmdlet in the background
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
@@ -66,7 +66,7 @@ Accept wildcard characters: False
Billing Scope
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
@@ -81,7 +81,7 @@ Accept wildcard characters: False
The credentials, account, tenant, and subscription used for communication with Azure.
```yaml
-Type: IAzureContextContainer
+Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential
@@ -92,11 +92,26 @@ Accept pipeline input: False
Accept wildcard characters: False
```
+### -ResellerId
+Reseller Id
+
+```yaml
+Type: System.String
+Parameter Sets: (All)
+Aliases:
+
+Required: False
+Position: Named
+Default value: None
+Accept pipeline input: False
+Accept wildcard characters: False
+```
+
### -SubscriptionId
Existing Subscription Id
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
@@ -111,11 +126,11 @@ Accept wildcard characters: False
Name of the subscription
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
-Required: True
+Required: False
Position: Named
Default value: None
Accept pipeline input: False
@@ -126,11 +141,11 @@ Accept wildcard characters: False
Type of Workload
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
-Required: True
+Required: False
Position: Named
Default value: None
Accept pipeline input: False
@@ -141,7 +156,7 @@ Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
@@ -157,7 +172,7 @@ Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
diff --git a/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
index 687bc7813dab..59a53aa05f98 100644
--- a/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
@@ -35,7 +35,7 @@ Deletes the subscription alias
Alias for the subscription
```yaml
-Type: String
+Type: System.String
Parameter Sets: (All)
Aliases:
@@ -50,7 +50,7 @@ Accept wildcard characters: False
Run cmdlet in the background
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
@@ -65,7 +65,7 @@ Accept wildcard characters: False
The credentials, account, tenant, and subscription used for communication with Azure.
```yaml
-Type: IAzureContextContainer
+Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzContext, AzureRmContext, AzureCredential
@@ -80,7 +80,7 @@ Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
@@ -96,7 +96,7 @@ Shows what would happen if the cmdlet runs.
The cmdlet is not run.
```yaml
-Type: SwitchParameter
+Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
From fe30da3ac37ed60b73e61b64eb03542aadfff323 Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Fri, 9 Oct 2020 11:30:29 -0700
Subject: [PATCH 7/9] Updated help
---
src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md | 2 +-
src/Subscription/Subscription/help/New-AzSubscriptionAlias.md | 2 +-
.../Subscription/help/Remove-AzSubscriptionAlias.md | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
index 72ec929f6156..8edd46d34c47 100644
--- a/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/Get-AzSubscriptionAlias.md
@@ -1,7 +1,7 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
Module Name: Az.Subscription
-online version:
+online version:https://docs.microsoft.com/en-us/powershell/module/az.subscription/get-azsubscriptionalias
schema: 2.0.0
---
diff --git a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
index 1f2c7e087ff0..a186be20d0cd 100644
--- a/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/New-AzSubscriptionAlias.md
@@ -1,7 +1,7 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
Module Name: Az.Subscription
-online version:
+online version:https://docs.microsoft.com/en-us/powershell/module/az.subscription/new-azsubscriptionalias
schema: 2.0.0
---
diff --git a/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
index 59a53aa05f98..b1737fce3457 100644
--- a/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
+++ b/src/Subscription/Subscription/help/Remove-AzSubscriptionAlias.md
@@ -1,7 +1,7 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Subscription.dll-Help.xml
Module Name: Az.Subscription
-online version:
+online version:https://docs.microsoft.com/en-us/powershell/module/az.subscription/remove-azsubscriptionalias
schema: 2.0.0
---
From d7a0739e97114a3d0e9dc06d282d0d0c8ba4d01d Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Fri, 9 Oct 2020 11:44:41 -0700
Subject: [PATCH 8/9] Updated tests
---
.../ScenarioTests/SubscriptionTests.ps1 | 4 +--
.../TestUpdateCancelSubscription.json | 26 +++++++++----------
.../TestUpdateRenameSubscription.json | 26 +++++++++----------
3 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1 b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
index b29d58c7e596..3ece0fd33123 100644
--- a/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
+++ b/src/Subscription/Subscription.Test/ScenarioTests/SubscriptionTests.ps1
@@ -18,7 +18,7 @@ Create subscription
#>
function Test-UpdateRenameSubscription
{
- $subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
+ $subId = "bc085fce-1a23-4734-b588-7c36b622317e"
$updateSub = Update-AzSubscription -SubscriptionId $subId -Action "Rename" -Name "RenameFromPowershell"
@@ -27,7 +27,7 @@ function Test-UpdateRenameSubscription
function Test-UpdateCancelSubscription
{
- $subId = "21cba39d-cbbc-487f-9749-43c5c960f269"
+ $subId = "bc085fce-1a23-4734-b588-7c36b622317e"
$updateSub = Update-AzSubscription -SubscriptionId $subId -Action "Cancel"
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateCancelSubscription.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateCancelSubscription.json
index 51795c6a7ec3..924e701eddd0 100644
--- a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateCancelSubscription.json
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateCancelSubscription.json
@@ -1,22 +1,22 @@
{
"Entries": [
{
- "RequestUri": "/subscriptions/21cba39d-cbbc-487f-9749-43c5c960f269/providers/Microsoft.Subscription/cancel?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMjFjYmEzOWQtY2JiYy00ODdmLTk3NDktNDNjNWM5NjBmMjY5L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2NhbmNlbD9hcGktdmVyc2lvbj0yMDE5LTEwLTAxLXByZXZpZXc=",
+ "RequestUri": "/subscriptions/bc085fce-1a23-4734-b588-7c36b622317e/providers/Microsoft.Subscription/cancel?api-version=2020-09-01",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYmMwODVmY2UtMWEyMy00NzM0LWI1ODgtN2MzNmI2MjIzMTdlL3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL2NhbmNlbD9hcGktdmVyc2lvbj0yMDIwLTA5LTAx",
"RequestMethod": "POST",
"RequestBody": "",
"RequestHeaders": {
"x-ms-client-request-id": [
- "2dfb692e-f389-4264-ae26-bb79e7c64574"
+ "2fb37549-1be1-434a-9594-552fc7be902f"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
- "FxVersion/4.6.27817.03",
+ "FxVersion/4.6.29220.03",
"OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.18363.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
+ "OSVersion/Microsoft.Windows.10.0.19042.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
]
},
"ResponseHeaders": {
@@ -33,10 +33,10 @@
"1199"
],
"x-ms-correlation-request-id": [
- "0b8fdd49-96e1-424b-a0d1-725451e072bc"
+ "e83a70af-9a8d-4dce-9d99-8d85594e2d00"
],
"request-id": [
- "0b8fdd49-96e1-424b-a0d1-725451e072bc"
+ "e83a70af-9a8d-4dce-9d99-8d85594e2d00"
],
"x-gsm": [
"1.0.0.0"
@@ -54,16 +54,16 @@
"ASP.NET"
],
"x-ms-request-id": [
- "0b8fdd49-96e1-424b-a0d1-725451e072bc"
+ "e83a70af-9a8d-4dce-9d99-8d85594e2d00"
],
"x-ms-routing-request-id": [
- "WESTUS:20200619T225218Z:0b8fdd49-96e1-424b-a0d1-725451e072bc"
+ "WESTUS:20201009T184351Z:e83a70af-9a8d-4dce-9d99-8d85594e2d00"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
],
"Date": [
- "Fri, 19 Jun 2020 22:52:17 GMT"
+ "Fri, 09 Oct 2020 18:43:50 GMT"
],
"Content-Length": [
"57"
@@ -75,12 +75,12 @@
"-1"
]
},
- "ResponseBody": "{\r\n \"subscriptionId\": \"21cba39d-cbbc-487f-9749-43c5c960f269\"\r\n}",
+ "ResponseBody": "{\r\n \"subscriptionId\": \"bc085fce-1a23-4734-b588-7c36b622317e\"\r\n}",
"StatusCode": 200
}
],
"Names": {},
"Variables": {
- "SubscriptionId": "21cba39d-cbbc-487f-9749-43c5c960f269"
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
}
}
\ No newline at end of file
diff --git a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateRenameSubscription.json b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateRenameSubscription.json
index 9e14f81bdcc5..f1037752619f 100644
--- a/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateRenameSubscription.json
+++ b/src/Subscription/Subscription.Test/SessionRecords/Subscription.Test.ScenarioTests.SubscriptionTests/TestUpdateRenameSubscription.json
@@ -1,22 +1,22 @@
{
"Entries": [
{
- "RequestUri": "/subscriptions/21cba39d-cbbc-487f-9749-43c5c960f269/providers/Microsoft.Subscription/rename?api-version=2019-10-01-preview",
- "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvMjFjYmEzOWQtY2JiYy00ODdmLTk3NDktNDNjNWM5NjBmMjY5L3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3JlbmFtZT9hcGktdmVyc2lvbj0yMDE5LTEwLTAxLXByZXZpZXc=",
+ "RequestUri": "/subscriptions/bc085fce-1a23-4734-b588-7c36b622317e/providers/Microsoft.Subscription/rename?api-version=2020-09-01",
+ "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYmMwODVmY2UtMWEyMy00NzM0LWI1ODgtN2MzNmI2MjIzMTdlL3Byb3ZpZGVycy9NaWNyb3NvZnQuU3Vic2NyaXB0aW9uL3JlbmFtZT9hcGktdmVyc2lvbj0yMDIwLTA5LTAx",
"RequestMethod": "POST",
"RequestBody": "{\r\n \"subscriptionName\": \"RenameFromPowershell\"\r\n}",
"RequestHeaders": {
"x-ms-client-request-id": [
- "07b39a23-6005-465f-adf2-c088d0ab601d"
+ "c3d532bd-3477-4778-8a2b-3827dbf61523"
],
"Accept-Language": [
"en-US"
],
"User-Agent": [
- "FxVersion/4.6.27817.03",
+ "FxVersion/4.6.29220.03",
"OSName/Windows",
- "OSVersion/Microsoft.Windows.10.0.18363.",
- "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.4.0"
+ "OSVersion/Microsoft.Windows.10.0.19042.",
+ "Microsoft.Azure.Management.Subscription.SubscriptionClient/1.1.5.0"
],
"Content-Type": [
"application/json; charset=utf-8"
@@ -39,10 +39,10 @@
"1199"
],
"x-ms-correlation-request-id": [
- "aa0d95c5-3b21-4ee4-97d0-91fb5a735293"
+ "dffdc6a0-eee5-4bb2-850a-fd49f6d343fd"
],
"request-id": [
- "aa0d95c5-3b21-4ee4-97d0-91fb5a735293"
+ "dffdc6a0-eee5-4bb2-850a-fd49f6d343fd"
],
"x-gsm": [
"1.0.0.0"
@@ -60,16 +60,16 @@
"ASP.NET"
],
"x-ms-request-id": [
- "aa0d95c5-3b21-4ee4-97d0-91fb5a735293"
+ "dffdc6a0-eee5-4bb2-850a-fd49f6d343fd"
],
"x-ms-routing-request-id": [
- "WESTUS:20200619T224730Z:aa0d95c5-3b21-4ee4-97d0-91fb5a735293"
+ "WESTUS:20201009T184326Z:dffdc6a0-eee5-4bb2-850a-fd49f6d343fd"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubDomains"
],
"Date": [
- "Fri, 19 Jun 2020 22:47:29 GMT"
+ "Fri, 09 Oct 2020 18:43:25 GMT"
],
"Content-Length": [
"57"
@@ -81,12 +81,12 @@
"-1"
]
},
- "ResponseBody": "{\r\n \"subscriptionId\": \"21cba39d-cbbc-487f-9749-43c5c960f269\"\r\n}",
+ "ResponseBody": "{\r\n \"subscriptionId\": \"bc085fce-1a23-4734-b588-7c36b622317e\"\r\n}",
"StatusCode": 200
}
],
"Names": {},
"Variables": {
- "SubscriptionId": "21cba39d-cbbc-487f-9749-43c5c960f269"
+ "SubscriptionId": "5b47c35e-863f-4c66-ba9f-52b9d0ced037"
}
}
\ No newline at end of file
From 39c09bc910b0b2efdd4b0e2b3b1435d920ccad7f Mon Sep 17 00:00:00 2001
From: navysingla <47647464+navysingla@users.noreply.github.com>
Date: Mon, 12 Oct 2020 10:47:57 -0700
Subject: [PATCH 9/9] Update ChangeLog.md
---
src/Subscription/Subscription/ChangeLog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Subscription/Subscription/ChangeLog.md b/src/Subscription/Subscription/ChangeLog.md
index 58518b9c5e69..90a034b869dd 100644
--- a/src/Subscription/Subscription/ChangeLog.md
+++ b/src/Subscription/Subscription/ChangeLog.md
@@ -18,7 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
-* Added new cmdlets `New-AzSubscriptionAlias` and Removed cmdlet `New-AzSubscription`
+* Added new cmdlets `New-AzSubscriptionAlias`,`Get-AzSubscriptionAlias`,`Remove-AzSubscriptionAlias` and Removed cmdlet `New-AzSubscription`
## Version 0.7.3
* Added new cmdlet `Update-AzSubscription`