You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/README.md
+96-36Lines changed: 96 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This repo deploys and remediates a custom Azure Policy that configures and enforces Arc-enabled SQL Server extension `LicenseType` to a selected target value (for example `Paid` or `PAYG`).
|`ManagementGroupId`|Yes|N/A | Any valid management group ID | Scope where the policy definition is created. |
24
+
|`ManagementGroupId`|No|Tenant root group | Any valid management group ID | Scope where the policy definition is created. Defaults to the tenant root management group when not specified. |
25
25
|`ExtensionType`| No |`Both`|`Windows`, `Linux`, `Both`| Targets the Arc SQL extension platform. When `Both` (default), a single policy definition and assignment covers both platforms. When a specific type is selected, the naming and scope are tailored to that platform. |
26
26
|`SubscriptionId`| No | Not set | Any valid subscription ID | If provided, policy assignment scope is the subscription. |
27
27
|`TargetLicenseType`| Yes | N/A |`Paid`, `PAYG`| Target `LicenseType` value to enforce. |
28
28
|`LicenseTypesToOverwrite`| No | All |`Unspecified`, `Paid`, `PAYG`, `LicenseOnly`| Select which current license states are eligible for update. Use `Unspecified` to include resources with no `LicenseType` configured. |
Note:`scripts/deployment.ps1` automatically grants required roles to the policy assignment managed identity at assignment scope, preventing common `PolicyAuthorizationFailed` errors during DeployIfNotExists deployments.
108
+
> **Note:**`deployment.ps1` automatically grants required roles to the policy assignment managed identity at assignment scope, preventing common `PolicyAuthorizationFailed` errors during DeployIfNotExists deployments.
|`ManagementGroupId`|Yes|N/A | Any valid management group ID | Used to resolve the policy definition/assignment naming context. |
116
+
|`ManagementGroupId`|No|Tenant root group | Any valid management group ID | Used to resolve the policy definition/assignment naming context. Defaults to the tenant root management group when not specified. |
82
117
|`ExtensionType`| No |`Both`|`Windows`, `Linux`, `Both`| Must match the platform used for the assignment. When `Both` (default), remediates the combined assignment. |
83
118
|`SubscriptionId`| No | Not set | Any valid subscription ID | If provided, remediation runs at subscription scope. |
84
119
|`TargetLicenseType`| Yes | N/A |`Paid`, `PAYG`| Must match the assignment target license type. |
85
120
|`GrantMissingPermissions`| No |`false`| Switch (`present`/`not present`) | If set, checks and assigns missing required roles before remediation. |
86
121
122
+
1. Set your variables. `TargetLicenseType` is required and must match the value used during deployment — all others are optional.
> **Note:** Use `-GrantMissingPermissions` to automatically check and assign any missing required roles before remediation starts.
153
+
154
+
## Recurring Billing Consent (PAYG)
155
+
156
+
When `TargetLicenseType` is set to `PAYG`, the policy automatically includes `ConsentToRecurringPAYG` in the extension settings with `Consented: true` and a UTC timestamp. This is required for recurring pay-as-you-go billing as described in the [Microsoft documentation](https://learn.microsoft.com/en-us/sql/sql-server/azure-arc/manage-pay-as-you-go-transition?view=sql-server-ver17#recurring-billing-consent).
157
+
158
+
The policy also checks for `ConsentToRecurringPAYG` in its compliance evaluation — resources with `LicenseType: PAYG` but missing the consent property are flagged as non-compliant and remediated. This applies both when transitioning to PAYG and for existing PAYG extensions that predate the consent requirement (backward compatibility).
159
+
160
+
> **Note:** Once `ConsentToRecurringPAYG` is set on an extension, it cannot be removed — this is enforced by the Azure resource provider. When transitioning away from PAYG, the policy changes `LicenseType` but leaves the consent property in place.
161
+
95
162
## Managed Identity And Roles
96
163
97
164
The policy assignment is created with `-IdentityType SystemAssigned`. Azure creates a managed identity on the assignment and uses it to apply DeployIfNotExists changes during enforcement and remediation.
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/policy/azurepolicy.json
+43-4Lines changed: 43 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
{
2
-
"displayName": "Set Arc-enabled SQL Server license type to 'License With Software Assurance'",
2
+
"displayName": "Configure Arc-enabled SQL Server license type",
3
3
"policyType": "Custom",
4
4
"mode": "Indexed",
5
-
"description": "This policy sets the license type for Arc-enabled SQL Server to 'License With Software Assurance'. ",
5
+
"description": "This policy configures the license type for Arc-enabled SQL Server extensions to a specified target value.",
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/scripts/deployment.ps1
+32-16Lines changed: 32 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
param(
2
-
[Parameter(Mandatory=$true)]
2
+
[Parameter(Mandatory=$false)]
3
3
[ValidateNotNullOrEmpty()]
4
4
[string]$ManagementGroupId,
5
5
@@ -23,6 +23,11 @@ param(
23
23
[switch]$SkipManagedIdentityRoleAssignment
24
24
)
25
25
26
+
if (-not$PSBoundParameters.ContainsKey('ManagementGroupId')) {
27
+
$ManagementGroupId= (Get-AzContext).Tenant.Id
28
+
Write-Output"ManagementGroupId not specified. Using tenant root management group: $ManagementGroupId"
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/scripts/start-remediation.ps1
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
param(
2
-
[Parameter(Mandatory=$true)]
2
+
[Parameter(Mandatory=$false)]
3
3
[ValidateNotNullOrEmpty()]
4
4
[string]$ManagementGroupId,
5
5
@@ -31,6 +31,11 @@ param(
31
31
[switch]$GrantMissingPermissions
32
32
)
33
33
34
+
if (-not$PSBoundParameters.ContainsKey('ManagementGroupId')) {
35
+
$ManagementGroupId= (Get-AzContext).Tenant.Id
36
+
Write-Output"ManagementGroupId not specified. Using tenant root management group: $ManagementGroupId"
0 commit comments