diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/README.md b/infra-as-code/bicep/CRML/subscriptionAlias/README.md
index 7af44804e..e70770fd1 100644
--- a/infra-as-code/bicep/CRML/subscriptionAlias/README.md
+++ b/infra-as-code/bicep/CRML/subscriptionAlias/README.md
@@ -14,7 +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. | 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. | 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` |
## Outputs
@@ -27,6 +31,8 @@ outSubscriptionId | string | `5583f55f-65b2-4a3a-87c9-e499c1c587c0`
## Deployment
+> **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.
@@ -35,7 +41,7 @@ In this example, the Subscription is created upon an EA Account through a tenant
```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
```
@@ -44,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/parameters/subscriptionAlias.parameters.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.example.json
new file mode 100644
index 000000000..f5ae42859
--- /dev/null
+++ b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.example.json
@@ -0,0 +1,29 @@
+{
+ "$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"
+ },
+ "parTags": {
+ "value": {
+ "Environment": "POC"
+ }
+ },
+ "parManagementGroupId": {
+ "value": "mg-example-001"
+ },
+ "parSubscriptionOwnerId": {
+ "value": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
+ },
+ "parSubscriptionOfferType": {
+ "value": "Production"
+ },
+ "parTenantId": {
+ "value": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
+ }
+ }
+}
\ No newline at end of file
diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json
similarity index 83%
rename from infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json
rename to infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json
index 9f6525bb1..157aa4491 100644
--- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.parameters.example.json
+++ b/infra-as-code/bicep/CRML/subscriptionAlias/parameters/subscriptionAlias.parameters.minimum.example.json
@@ -7,9 +7,6 @@
},
"parSubscriptionBillingScope": {
"value": "/providers/Microsoft.Billing/billingAccounts/XXXXXXX/enrollmentAccounts/XXXXXX"
- },
- "parSubscriptionOfferType": {
- "value": "Production"
}
}
}
\ No newline at end of file
diff --git a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep
index cde375558..ab42828ce 100644
--- a/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep
+++ b/infra-as-code/bicep/CRML/subscriptionAlias/subscriptionAlias.bicep
@@ -1,8 +1,10 @@
/*
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
+AUTHOR/S: jtracey93, johnlokerse
+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 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)')
+param parSubscriptionOwnerId string = ''
+
@allowed([
'DevTest'
'Production'
@@ -20,9 +31,18 @@ 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' = {
+@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: {
+ additionalProperties: {
+ tags: parTags
+ managementGroupId: empty(parManagementGroupId) ? json('null') : managementGroup(parManagementGroupId)
+ subscriptionOwnerId: empty(parSubscriptionOwnerId) ? json('null') : parSubscriptionOwnerId
+ subscriptionTenantId: parTenantId
+ }
displayName: parSubscriptionName
billingScope: parSubscriptionBillingScope
workload: parSubscriptionOfferType
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"