From 51e16b2c3572c157a17cf50d7c4bffa37e805e47 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Mar 2022 15:40:44 +0200 Subject: [PATCH 01/12] Upped aliases API version to non-preview Checked if the current properties are still valid. With the newer version `Microsoft.Subscription/aliases` there are more properties present, tags for example. Link to msdocs: https://docs.microsoft.com/en-us/azure/templates/microsoft.subscription/2021-10-01/aliases?tabs=bicep --- .../bicep/CRML/subscriptionAlias/subscriptionAlias.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index cde375558..389d85f62 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -20,7 +20,7 @@ param parSubscriptionBillingScope string @description('The offer type of the EA, MCA or MPA subscription to be created. Defaults to = Production') param parSubscriptionOfferType string = 'Production' -resource resSubscription 'Microsoft.Subscription/aliases@2019-10-01-preview' = { +resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { name: parSubscriptionName properties: { displayName: parSubscriptionName From 36d2494bfa82820a74ea7efa13cddc8df9b18bcb Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Mar 2022 17:05:06 +0200 Subject: [PATCH 02/12] Added parTags, parManagementGroupId, parSubscriptionOwnerId --- .../subscriptionAlias/subscriptionAlias.bicep | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index 389d85f62..aa4303782 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -2,7 +2,9 @@ SUMMARY: The Subscription Alias module deploys an EA, MCA or MPA Subscription into the tenants default Management Group DESCRIPTION: The Subscription Alias module deploys an EA, MCA or MPA Subscription into the tenants default Management Group as per the docs here: https://docs.microsoft.com/azure/cost-management-billing/manage/programmatically-create-subscription AUTHOR/S: jtracey93 -VERSION: 1.0.0 +VERSION: 1.1.0 + - Updated version of the API + - Added additional properties: parTags, parManagementGroupId, parSubscriptionOwnerId and subscriptionTenantId */ targetScope = 'tenant' @@ -13,6 +15,15 @@ param parSubscriptionName string @description('The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in.') param parSubscriptionBillingScope string +@description('Tags you would like to be applied') +param parTags object = {} + +@description('The ID of the management group where the subscription will be placed. Also known as the parent management group.') +param parManagementGroupId string + +@description('The ID of the responsible user for the subscription.') +param parSubscriptionOwnerId string + @allowed([ 'DevTest' 'Production' @@ -23,6 +34,12 @@ param parSubscriptionOfferType string = 'Production' resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { name: parSubscriptionName properties: { + additionalProperties: { + tags: parTags + managementGroupId: parManagementGroupId + subscriptionOwnerId: parSubscriptionOwnerId + subscriptionTenantId: tenant().tenantId + } displayName: parSubscriptionName billingScope: parSubscriptionBillingScope workload: parSubscriptionOfferType From cc3c3816134f56635f91b76c1f49447d94add36e Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Mar 2022 17:05:24 +0200 Subject: [PATCH 03/12] Updated readme, updated example params --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 3 +++ .../subscriptionAlias.parameters.example.json | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 7af44804e..503f5dbd8 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -14,6 +14,9 @@ The module requires the following inputs: | ----------- | ---- | ----------- | ------------ | ------- | -------- | parSubscriptionName | string | Name of the subscription to be created. Will also be used as the alias name. Whilst you can use any name you like we recommend it to be: all lowercase, no spaces, alphanumeric and hyphens only. | Yes | `sub-example-001` | None, must be provided. | parSubscriptionBillingScope | string | The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in. | Yes | EA - `/providers/Microsoft.Billing/BillingAccounts/1234567/enrollmentAccounts/7654321`
MCA - `/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx`
MPA - `/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | None, must be provided. | +parTags | object | Tags you would like to be applied | Yes | | | +parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| Yes | | | +parSubscriptionOwnerId | string | The ID of the responsible user for the subscription. | Yes | | | parSubscriptionOfferType | string | The offer type of the EA, MCA or MPA subscription to be created. | No | `DevTest` | `Production` | ## Outputs diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json index 9f6525bb1..c75b0eb61 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json @@ -8,6 +8,17 @@ "parSubscriptionBillingScope": { "value": "/providers/Microsoft.Billing/billingAccounts/XXXXXXX/enrollmentAccounts/XXXXXX" }, + "parTags": { + "value": { + "Environment": "POC" + } + }, + "parManagementGroupId": { + "value": "mg-example-001" + }, + "parSubscriptionOwnerId": { + "value": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" + }, "parSubscriptionOfferType": { "value": "Production" } From f43008e6f6fc8e39d1365630ae14b9a0b4e3b5d5 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 30 Mar 2022 19:05:15 +0200 Subject: [PATCH 04/12] Implemented review feedback Added input examples, added parTenantId, added author name, updated description of subscriptionOwnerId --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 7 ++++--- .../CRML/subscriptionAlias/subscriptionAlias.bicep | 11 +++++++---- .../subscriptionAlias.parameters.example.json | 3 +++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 503f5dbd8..9dca547e7 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -14,10 +14,11 @@ The module requires the following inputs: | ----------- | ---- | ----------- | ------------ | ------- | -------- | parSubscriptionName | string | Name of the subscription to be created. Will also be used as the alias name. Whilst you can use any name you like we recommend it to be: all lowercase, no spaces, alphanumeric and hyphens only. | Yes | `sub-example-001` | None, must be provided. | parSubscriptionBillingScope | string | The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in. | Yes | EA - `/providers/Microsoft.Billing/BillingAccounts/1234567/enrollmentAccounts/7654321`
MCA - `/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx`
MPA - `/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | None, must be provided. | -parTags | object | Tags you would like to be applied | Yes | | | -parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| Yes | | | -parSubscriptionOwnerId | string | The ID of the responsible user for the subscription. | Yes | | | +parTags | object | Tags you would like to be applied. | Yes | `{"key": "value"}` | Empty object `{}` | +parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| Yes | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | | +parSubscriptionOwnerId | string | The object ID of a responsible user, AAD group or service principal. | Yes | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | | parSubscriptionOfferType | string | The offer type of the EA, MCA or MPA subscription to be created. | No | `DevTest` | `Production` | +parTenantId | string | The ID of the tenant. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | `tenant().tenantId` | ## Outputs diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index aa4303782..f7d844b5f 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -1,7 +1,7 @@ /* SUMMARY: The Subscription Alias module deploys an EA, MCA or MPA Subscription into the tenants default Management Group DESCRIPTION: The Subscription Alias module deploys an EA, MCA or MPA Subscription into the tenants default Management Group as per the docs here: https://docs.microsoft.com/azure/cost-management-billing/manage/programmatically-create-subscription -AUTHOR/S: jtracey93 +AUTHOR/S: jtracey93, johnlokerse VERSION: 1.1.0 - Updated version of the API - Added additional properties: parTags, parManagementGroupId, parSubscriptionOwnerId and subscriptionTenantId @@ -15,13 +15,13 @@ param parSubscriptionName string @description('The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in.') param parSubscriptionBillingScope string -@description('Tags you would like to be applied') +@description('Tags you would like to be applied.') param parTags object = {} @description('The ID of the management group where the subscription will be placed. Also known as the parent management group.') param parManagementGroupId string -@description('The ID of the responsible user for the subscription.') +@description('The object ID of a responsible user, AAD group or service principal.') param parSubscriptionOwnerId string @allowed([ @@ -31,6 +31,9 @@ param parSubscriptionOwnerId string @description('The offer type of the EA, MCA or MPA subscription to be created. Defaults to = Production') param parSubscriptionOfferType string = 'Production' +@description('The ID of the tenant. Defaults to = tenant().tenantId') +param parTenantId string = tenant().tenantId + resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { name: parSubscriptionName properties: { @@ -38,7 +41,7 @@ resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { tags: parTags managementGroupId: parManagementGroupId subscriptionOwnerId: parSubscriptionOwnerId - subscriptionTenantId: tenant().tenantId + subscriptionTenantId: parTenantId } displayName: parSubscriptionName billingScope: parSubscriptionBillingScope diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json index c75b0eb61..f5ae42859 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json @@ -21,6 +21,9 @@ }, "parSubscriptionOfferType": { "value": "Production" + }, + "parTenantId": { + "value": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx" } } } \ No newline at end of file From 0851411210ede4df094306e5f1455cf1bb2ff40b Mon Sep 17 00:00:00 2001 From: John Lokerse Date: Thu, 31 Mar 2022 15:09:46 +0200 Subject: [PATCH 05/12] Added managementGroup reference --- .../bicep/CRML/subscriptionAlias/subscriptionAlias.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index f7d844b5f..98a09ddb8 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -39,7 +39,7 @@ resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { properties: { additionalProperties: { tags: parTags - managementGroupId: parManagementGroupId + managementGroupId: managementGroup(parManagementGroupId) subscriptionOwnerId: parSubscriptionOwnerId subscriptionTenantId: parTenantId } From 478a4a3266b31eb93b5852aa2490c08b7db42164 Mon Sep 17 00:00:00 2001 From: John Lokerse Date: Thu, 31 Mar 2022 15:28:19 +0200 Subject: [PATCH 06/12] Made parManagementGroupId, parSubscriptionOwnerId optional --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 6 +++--- .../CRML/subscriptionAlias/subscriptionAlias.bicep | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 9dca547e7..ba69032ec 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -14,9 +14,9 @@ The module requires the following inputs: | ----------- | ---- | ----------- | ------------ | ------- | -------- | parSubscriptionName | string | Name of the subscription to be created. Will also be used as the alias name. Whilst you can use any name you like we recommend it to be: all lowercase, no spaces, alphanumeric and hyphens only. | Yes | `sub-example-001` | None, must be provided. | parSubscriptionBillingScope | string | The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in. | Yes | EA - `/providers/Microsoft.Billing/BillingAccounts/1234567/enrollmentAccounts/7654321`
MCA - `/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx`
MPA - `/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | None, must be provided. | -parTags | object | Tags you would like to be applied. | Yes | `{"key": "value"}` | Empty object `{}` | -parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| Yes | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | | -parSubscriptionOwnerId | string | The object ID of a responsible user, AAD group or service principal. | Yes | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | | +parTags | object | Tags you would like to be applied. | No | `{"key": "value"}` | Empty object `{}` | +parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| No | `mg-root` | Empty string | +parSubscriptionOwnerId | string | The object ID of a responsible user, AAD group or service principal. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | Empty string | parSubscriptionOfferType | string | The offer type of the EA, MCA or MPA subscription to be created. | No | `DevTest` | `Production` | parTenantId | string | The ID of the tenant. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | `tenant().tenantId` | diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index 98a09ddb8..427299cd2 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -18,11 +18,11 @@ param parSubscriptionBillingScope string @description('Tags you would like to be applied.') param parTags object = {} -@description('The ID of the management group where the subscription will be placed. Also known as the parent management group.') -param parManagementGroupId string +@description('The ID of the management group where the subscription will be placed. Also known as the parent management group. (Optional)') +param parManagementGroupId string = '' -@description('The object ID of a responsible user, AAD group or service principal.') -param parSubscriptionOwnerId string +@description('The object ID of a responsible user, AAD group or service principal. (Optional)') +param parSubscriptionOwnerId string = '' @allowed([ 'DevTest' @@ -39,8 +39,8 @@ resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { properties: { additionalProperties: { tags: parTags - managementGroupId: managementGroup(parManagementGroupId) - subscriptionOwnerId: parSubscriptionOwnerId + managementGroupId: empty(parManagementGroupId) ? managementGroup(parManagementGroupId) : json('null') + subscriptionOwnerId: empty(parSubscriptionOwnerId) ? parSubscriptionOwnerId : json('null') subscriptionTenantId: parTenantId } displayName: parSubscriptionName From 8f669213676bc1827fc92ff3f49b9ffdc01f558a Mon Sep 17 00:00:00 2001 From: John Lokerse Date: Thu, 31 Mar 2022 15:35:16 +0200 Subject: [PATCH 07/12] Turned the ternary check around --- .../bicep/CRML/subscriptionAlias/subscriptionAlias.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index 427299cd2..441e1ad7a 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -39,8 +39,8 @@ resource resSubscription 'Microsoft.Subscription/aliases@2021-10-01' = { properties: { additionalProperties: { tags: parTags - managementGroupId: empty(parManagementGroupId) ? managementGroup(parManagementGroupId) : json('null') - subscriptionOwnerId: empty(parSubscriptionOwnerId) ? parSubscriptionOwnerId : json('null') + managementGroupId: empty(parManagementGroupId) ? json('null') : managementGroup(parManagementGroupId) + subscriptionOwnerId: empty(parSubscriptionOwnerId) ? json('null') : parSubscriptionOwnerId subscriptionTenantId: parTenantId } displayName: parSubscriptionName From 0df3af02dc23543df05169b904b53a451d11b142 Mon Sep 17 00:00:00 2001 From: John Lokerse Date: Thu, 31 Mar 2022 16:07:29 +0200 Subject: [PATCH 08/12] Typo fixes --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 2 +- .../bicep/CRML/subscriptionAlias/subscriptionAlias.bicep | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index ba69032ec..6b0bfc220 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -15,7 +15,7 @@ The module requires the following inputs: parSubscriptionName | string | Name of the subscription to be created. Will also be used as the alias name. Whilst you can use any name you like we recommend it to be: all lowercase, no spaces, alphanumeric and hyphens only. | Yes | `sub-example-001` | None, must be provided. | parSubscriptionBillingScope | string | The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in. | Yes | EA - `/providers/Microsoft.Billing/BillingAccounts/1234567/enrollmentAccounts/7654321`
MCA - `/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx`
MPA - `/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | None, must be provided. | parTags | object | Tags you would like to be applied. | No | `{"key": "value"}` | Empty object `{}` | -parManagementGroupId | string | The ID of the management group where the subscription will be placed. Also known as the parent management group.| No | `mg-root` | Empty string | +parManagementGroupId | string | The ID of the existing management group where the subscription will be placed. Also known as it's parent management group. (Optional) | No | `mg-root` | Empty string | parSubscriptionOwnerId | string | The object ID of a responsible user, AAD group or service principal. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | Empty string | parSubscriptionOfferType | string | The offer type of the EA, MCA or MPA subscription to be created. | No | `DevTest` | `Production` | parTenantId | string | The ID of the tenant. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | `tenant().tenantId` | diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep index 441e1ad7a..ab42828ce 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep +++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep @@ -18,7 +18,7 @@ param parSubscriptionBillingScope string @description('Tags you would like to be applied.') param parTags object = {} -@description('The ID of the management group where the subscription will be placed. Also known as the parent management group. (Optional)') +@description('The ID of the existing management group where the subscription will be placed. Also known as its parent management group. (Optional)') param parManagementGroupId string = '' @description('The object ID of a responsible user, AAD group or service principal. (Optional)') From 46a1ff09351512e4fd69e9ab2594d6b86eb7629f Mon Sep 17 00:00:00 2001 From: John Lokerse Date: Thu, 31 Mar 2022 16:08:36 +0200 Subject: [PATCH 09/12] Removed (optional) in README --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 6b0bfc220..1b1a7ec81 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -15,7 +15,7 @@ The module requires the following inputs: parSubscriptionName | string | Name of the subscription to be created. Will also be used as the alias name. Whilst you can use any name you like we recommend it to be: all lowercase, no spaces, alphanumeric and hyphens only. | Yes | `sub-example-001` | None, must be provided. | parSubscriptionBillingScope | string | The full resource ID of billing scope associated to the EA, MCA or MPA account you wish to create the subscription in. | Yes | EA - `/providers/Microsoft.Billing/BillingAccounts/1234567/enrollmentAccounts/7654321`
MCA - `/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx`
MPA - `/providers/Microsoft.Billing/billingAccounts/99a13315-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/customers/2281f543-xxxx-xxxx-xxxx-xxxxxxxxxxxx` | None, must be provided. | parTags | object | Tags you would like to be applied. | No | `{"key": "value"}` | Empty object `{}` | -parManagementGroupId | string | The ID of the existing management group where the subscription will be placed. Also known as it's parent management group. (Optional) | No | `mg-root` | Empty string | +parManagementGroupId | string | The ID of the existing management group where the subscription will be placed. Also known as it's parent management group. | No | `mg-root` | Empty string | parSubscriptionOwnerId | string | The object ID of a responsible user, AAD group or service principal. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | Empty string | parSubscriptionOfferType | string | The offer type of the EA, MCA or MPA subscription to be created. | No | `DevTest` | `Production` | parTenantId | string | The ID of the tenant. | No | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx` | `tenant().tenantId` | From 9829c37d1e0450daf691f239dee9e38302944990 Mon Sep 17 00:00:00 2001 From: Jack Tracey <41163455+jtracey93@users.noreply.github.com> Date: Fri, 1 Apr 2022 16:42:24 +0000 Subject: [PATCH 10/12] updates to params min and location for upcomming change and update tests --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 6 ++++-- .../subscriptionAlias.parameters.example.json | 0 ...subscriptionAlias.parameters.minimum.example.json | 12 ++++++++++++ tests/pipelines/bicep-build-to-validate.yml | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) rename infra-as-code/bicep/CRML/subscriptionAlias/{ => parameters}/subscriptionAlias.parameters.example.json (100%) create mode 100644 infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 1b1a7ec81..9e7906268 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -35,11 +35,13 @@ In this example, the Subscription is created upon an EA Account through a tenant > For the below examples we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice. +> **Important Note:** There are 2 parameter files examples provided in the `/parameters` folder of this module. One that contains examples of all possible parameters and another that only contains the minimum required parameters. The minimum version is used in the below examples. + ### Azure CLI ```bash az deployment tenant create \ --template-file infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep \ - --parameters @infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json \ + --parameters @infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json \ --location eastus ``` @@ -48,7 +50,7 @@ az deployment tenant create \ ```powershell New-AzTenantDeployment ` -TemplateFile infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep ` - -TemplateParameterFile infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json ` + -TemplateParameterFile infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json ` -Location eastus ``` diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.example.json similarity index 100% rename from infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json rename to infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.example.json diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json new file mode 100644 index 000000000..157aa4491 --- /dev/null +++ b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "parSubscriptionName": { + "value": "sub-example-001" + }, + "parSubscriptionBillingScope": { + "value": "/providers/Microsoft.Billing/billingAccounts/XXXXXXX/enrollmentAccounts/XXXXXX" + } + } +} \ No newline at end of file diff --git a/tests/pipelines/bicep-build-to-validate.yml b/tests/pipelines/bicep-build-to-validate.yml index cc8bbb7df..984e74599 100644 --- a/tests/pipelines/bicep-build-to-validate.yml +++ b/tests/pipelines/bicep-build-to-validate.yml @@ -89,7 +89,7 @@ jobs: inputs: targetType: 'inline' script: | - subid=$(az deployment tenant create --name "deploy-$(SubscriptionName)" --location $(Location) --template-file infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep --parameters @infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json --parameters parSubscriptionBillingScope=$(ALZ-AZURE-SECRET-EA-BILLING-ACCOUNT) parSubscriptionName=$(SubscriptionName) | jq .properties.outputs.outSubscriptionId.value | tr -d '"') + subid=$(az deployment tenant create --name "deploy-$(SubscriptionName)" --location $(Location) --template-file infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep --parameters @infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json --parameters parSubscriptionBillingScope=$(ALZ-AZURE-SECRET-EA-BILLING-ACCOUNT) parSubscriptionName=$(SubscriptionName) | jq .properties.outputs.outSubscriptionId.value | tr -d '"') echo $subId echo "##vso[task.setvariable variable=subscriptionId]$subid" echo "##vso[task.setvariable variable=IsDeployed;isoutput=true]$subid" From 8722630b1bebfb1febf65a250f77dc8113a65e34 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 1 Apr 2022 21:41:38 +0200 Subject: [PATCH 11/12] Removed block quote because of markdownlinter error --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 9e7906268..9a7e3a802 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -31,9 +31,7 @@ outSubscriptionId | string | `5583f55f-65b2-4a3a-87c9-e499c1c587c0` ## Deployment -In this example, the Subscription is created upon an EA Account through a tenant-scoped deployment. - -> For the below examples we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice. +In this example, the Subscription is created upon an EA Account through a tenant-scoped deployment. For the below examples we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice. > **Important Note:** There are 2 parameter files examples provided in the `/parameters` folder of this module. One that contains examples of all possible parameters and another that only contains the minimum required parameters. The minimum version is used in the below examples. From d0b18a8f4964911861172c50204cf59fa0355681 Mon Sep 17 00:00:00 2001 From: Jack Tracey <41163455+jtracey93@users.noreply.github.com> Date: Sat, 2 Apr 2022 10:46:03 +0100 Subject: [PATCH 12/12] changes for module docs consistency --- infra-as-code/bicep/CRML/subscriptionAlias/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md index 9a7e3a802..e70770fd1 100644 --- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md +++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md @@ -31,10 +31,12 @@ outSubscriptionId | string | `5583f55f-65b2-4a3a-87c9-e499c1c587c0` ## Deployment -In this example, the Subscription is created upon an EA Account through a tenant-scoped deployment. For the below examples we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice. - > **Important Note:** There are 2 parameter files examples provided in the `/parameters` folder of this module. One that contains examples of all possible parameters and another that only contains the minimum required parameters. The minimum version is used in the below examples. +In this example, the Subscription is created upon an EA Account through a tenant-scoped deployment. + +> For the below examples we assume you have downloaded or cloned the Git repo as-is and are in the root of the repository as your selected directory in your terminal of choice. + ### Azure CLI ```bash az deployment tenant create \