Skip to content

Commit fc2101d

Browse files
authored
Merge pull request #1390 from anosov1960/PAYG-transition
Merging new PAYG transition scripts
2 parents f3dc8c4 + b630705 commit fc2101d

10 files changed

Lines changed: 1765 additions & 850 deletions

File tree

samples/manage/.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"name": "PowerShell: Launch Current File",
10+
"type": "PowerShell",
11+
"request": "launch",
12+
"script": "${file}",
13+
"args": []
14+
}
15+
]
16+
}

samples/manage/azure-arc-enabled-sql-server/modify-license-type/README.md

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ ms.author: sashan
66
ms.date: 05/01/2025
77
---
88

9+
# About this sample
10+
11+
- **Applies to:** Arc-enabled SQL Server
12+
- **Workload:** n/a
13+
- **Programming Language:** PowerShell
14+
- **Authors:** Alexander (Sasha) Nosov
15+
- **Update history:**
16+
17+
05/01/2025 - added the consent parameter for teh CSP-managed subscriptions
18+
19+
05/09/2025 - added *-ReportOnly* and *-TenandId* parameters
20+
21+
05/13/2025 - added support for a .CSV file with the machine names
922

1023
# Overview
1124

@@ -27,66 +40,79 @@ The script accepts the following command line parameters:
2740

2841
| **Parameter**                                         | **Value**                                                                       | **Description** |
2942
|:--|:--|:--|
30-
|`-SubId`|subscription_id *or* a file_name|*Optional*: Subscription id or a .csv file with the list of subscriptions<sup>1</sup>. If not specified all subscriptions will be scanned|
31-
|`-ResourceGroup` |resource_group_name|*Optional*: Limits the scope to a specific resource group|
32-
|`-MachineName` |machine_name|*Optional*: Limits the scope to a specific machine|
33-
|`-LicenseType` | "Paid", "PAYG" or "LicenseOnly"| *Optional*: Sets the license type to the specified value |
34-
|`-ConsentToRecurringPAYG` | "Yes" or "No" |*Optional*. Consents to enabling the recurring PAYG billing. LicenseType must be "PAYG". Applies to CSP subscriptions only.|
35-
|`-UsePcoreLicense` | "Yes", "No" | *Optional*. Enables unlimited virtualization license if the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
36-
|`-EnableESU` | "Yes", "No" | *Optional*. Enables the ESU policy the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
43+
|`-SubId`|`subscription_id` *or* `file_name`|*Optional*: Subscription id or a .csv file with the list of subscriptions<sup>1</sup>. If not specified all subscriptions will be scanned|
44+
|`-ResourceGroup` |`resource_group_name`|*Optional*: Limits the scope to a specific resource group|
45+
|`-MachineName` |`machine_name`|*Optional*: A single machine name or a CSV file name containing a list of machine names<sup>2</sup>.|
46+
|`-LicenseType` | `Paid`, `PAYG` or `LicenseOnly`| *Optional*: Sets the license type to the specified value |
47+
|`-ConsentToRecurringPAYG` | `Yes`, `No` |*Optional*. Consents to enabling the recurring PAYG billing. LicenseType must be "PAYG". Applies to CSP subscriptions only.|
48+
|`-UsePcoreLicense` | `Yes`, `No` | *Optional*. Enables unlimited virtualization license if the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
49+
|`-EnableESU` | `Yes`, `No` | *Optional*. Enables the ESU policy the value is "Yes" or disables it if the value is "No". To enable, the license type must be "Paid" or "PAYG"|
3750
|`-Force`| |*Optional*. Forces the change of the license type to the specified value on all installed extensions. If `-Force` is not specified, the `-LicenseType` value is set only if undefined. Ignored if `-LicenseType` is not specified|
51+
|`-ExclusionTags`| `{"name":"value","name":"value"}` |*Optional*. If specified, excludes the resources that have this tag assigned.|
52+
|`-TenantId`| `tenant_id` |*Optional*. If specified, uses this tenant id to log in. Otherwise, the current context is used.|
53+
|`-ReportOnly`| |*Optional*. If true, generates a csv file with the list of resources that are to be modified, but doesn't make the actual change.|
54+
|`-UseManagedIdentity`| |*Optional*. If true, logs in both PowerShell and CLI using managed identity. Required to run the script as a runbook.|
3855

3956
<sup>1</sup>You can create a .csv file using the following command and then edit to remove the subscriptions you don't want to scan.
4057
```PowerShell
4158
Get-AzSubscription | Export-Csv .\mysubscriptions.csv -NoTypeInformation
4259
```
60+
<sup>2</sup>The .csv file must include a column *MachineName*. E.g.:
61+
```
62+
"MachineName",
63+
"Prod1",
64+
"Prod2",
65+
"Prod3"
66+
```
67+
68+
# Script execution examples
4369

4470
## Example 1
4571

46-
The following command will scan all the subscriptions to which the user has access to, and set the license type to "Paid" on all servers where license type is undefined.
72+
The following command will scan all the subscriptions in tenant `<tenant_id>`, and list the machines that would have the license type change to "PAYG" on all servers where license type is undefined.
4773

4874
```PowerShell
49-
.\modify-license-type.ps1 -LicenseType Paid
75+
.\modify-arc-sql-license-type.ps1 -TenantId <tenant_id> -LicenseType PAYG -ReportOnly
5076
```
5177

5278
## Example 2
5379

54-
The following command will scan the subscription `<sub_id>` and set the license type value to "Paid" on all servers.
80+
The following command will scan the subscription `<sub_id>` in the current tenant and set the license type value to "Paid" on all servers listed in `machines.csv`.
5581

5682
```PowerShell
57-
.\modify-license-type.ps1 -SubId <sub_id> -LicenseType Paid -Force
83+
.\modify-arc-sql-license-type.ps1 -SubId <sub_id> -MachineName machines.csv -LicenseType Paid -Force
5884
```
5985

6086
## Example 3
6187

62-
The following command will scan resource group `<resource_group_name>` in the subscription `<sub_id>`, set the license type value to "PAYG" and enable unlimited virtualization license on all servers in the specified resource group.
88+
The following command will scan resource group `<resource_group_name>` in the subscription `<sub_id>` within the current tenant, set the license type value to "PAYG" and enable unlimited virtualization license on all servers in the specified resource group.
6389

6490
```PowerShell
65-
.\modify-license-type.ps1 -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType PAYG -UsePcoreLicense Yes -Force
91+
.\modify-arc-sql-license-type.ps1 -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType PAYG -UsePcoreLicense Yes -Force
6692
```
6793

6894
## Example 4
6995

70-
The following command will set License Type to "Paid" and enables ESU on all servers in the subscriptions `<sub_id>` and the resource group `<resource_group_name>`.
96+
The following command will set License Type to "Paid" and enables ESU on all servers in the subscriptions `<sub_id>` of tenant `<tenant_id>` and the resource group `<resource_group_name>` except those with the tag `Environment:Dev`
7197

7298
```console
73-
.\modify-license-type.ps1 -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType Paid -EnableESU Yes -Force
99+
.\modify-arc-sql-license-type.ps1 -TenantId <tenant_id> -SubId <sub_id> -ResourceGroup <resource_group_name> -LicenseType Paid -EnableESU Yes -Force -ExclusionTags {"Environment":"Dev"}
74100
```
75101

76102
## Example 5
77103

78104
The following command will disable ESU on all servers in the subscriptions `<sub_id>`.
79105

80106
```console
81-
.\modify-license-type.ps1 -SubId <sub_id> -EnableESU No
107+
.\modify-arc-sql-license-type.ps1 -SubId <sub_id> -EnableESU No
82108
```
83109

84110
## Example 6
85111

86-
The following command will scan all subscriptions in the account, set the license type value to "PAYG" and consents to enabling recurring billing on all servers in the account.
112+
The following command will scan all subscriptions in the account using managed identity, set the license type value to "PAYG" and consents to enabling recurring billing on all servers in the account.
87113

88114
```PowerShell
89-
.\modify-license-type.ps1 -LicenseType PAYG -ConsentToRecurringPAYG Yes -Force
115+
.\modify-arc-sql-license-type.ps1 -LicenseType PAYG -ConsentToRecurringPAYG Yes -Force -UseManagedIdentity
90116
```
91117
> [!NOTE]
92118
> The recurring billing only supported in the CSP accounts.
@@ -97,7 +123,7 @@ This option is recommended because Cloud shell has the Azure PowerShell modules
97123

98124
1. Launch the [Cloud Shell](https://shell.azure.com/). For details, [read more about PowerShell in Cloud Shell](https://aka.ms/pscloudshell/docs).
99125

100-
1. Connect to Azure AD. You must specify `<tenant_id>` if you have access to more than one AAD tenants.
126+
1. Connect to Azure AD. You can skip this step if you specify `<tenant_id>` as a parameter of the script.
101127

102128
```console
103129
Connect-AzureAD -TenantID <tenant_id>
@@ -106,10 +132,10 @@ This option is recommended because Cloud shell has the Azure PowerShell modules
106132
1. Upload the script to your cloud shell using the following command:
107133

108134
```console
109-
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 -o modify-license-type.ps1
135+
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/modify-arc-sql-license-type/modify-arc-sql-license-type.ps1 -o modify-arc-sql-license-type.ps1
110136
```
111137

112-
1. Run the script.
138+
1. Run the script by following an appropriate example.
113139

114140
> [!NOTE]
115141
> - To paste the commands into the shell, use `Ctrl-Shift-V` on Windows or `Cmd-v` on MacOS.
@@ -123,27 +149,13 @@ Use the following steps to run the script in a PowerShell session on your PC.
123149
1. Copy the script to your current folder:
124150

125151
```console
126-
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/modify-license-type/modify-license-type.ps1 -o modify-license-type.ps1
127-
```
128-
129-
1. Make sure the NuGet package provider is installed:
130-
131-
```console
132-
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
133-
Install-packageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Scope CurrentUser -Force
134-
```
135-
136-
1. Make sure the the Az module is installed. For more information, see [Install the Azure Az PowerShell module](https://learn.microsoft.com/powershell/azure/install-az-ps):
137-
138-
```console
139-
Install-Module Az -Scope CurrentUser -Repository PSGallery -Force
152+
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/modify-arc-sql-license-type/modify-arc-sql-license-type.ps1 -o modify-arc-sql-license-type.ps1
140153
```
141154

142-
1. Connect to Azure AD and log in to your Azure account. You must specify `<tenant_id>` if you have access to more than one AAD tenants.
155+
1. Connect to Azure AD. You can skip this step if you specify `<tenant_id>` as a parameter of the script.
143156

144157
```console
145158
Connect-AzureAD -TenantID <tenant_id>
146-
Connect-AzAccount -TenantID (Get-AzureADTenantDetail).ObjectId
147159
```
148160

149-
1. Run the script.
161+
1. Run the script by following an appropriate example.

0 commit comments

Comments
 (0)