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-hybrid-benefit/README.md
+67-10Lines changed: 67 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,13 @@ services: Azure SQL
3
3
platforms: Azure
4
4
author: anosov1960
5
5
ms.author: sashan
6
-
ms.date: 12/17/2020
6
+
ms.date: 1/11/2021
7
7
---
8
8
9
9
# Overview
10
10
11
-
This script is provided to help you manage the SQL Server licenses that are consumed by the SQL Servers deployed to Azure. The script writes the results to a `sql-license-usage.csv` file. If the file with this name already exists, the new results will be appended to it. The report includes the following information for each scanned subscription as well as the totals for each category.
11
+
This script provided a simple solution to analyze adn track the consolidated utilization of SQL Server licenses by all of the SQL resources in a specific subscription or the entire the account. By default, the script scans all subscriptions the user account has access. Alternatively, you can specify a single subscription or a .CSV file with a list of subscription. The usage report includes the following information for each scanned subscription.
12
+
12
13
|**Category**|**Description**|
13
14
|:--|:--|
14
15
|Date|Date of the scan|
@@ -24,10 +25,67 @@ This script is provided to help you manage the SQL Server licenses that are cons
24
25
|Developer vCores|Total vCores used by SQL Server Developer edition|
25
26
|Express vCores|Total vCores used by SQL Server Express edition|
26
27
28
+
The following resources are in scope for the license utilization analysis:
29
+
- Azure SQL databases (vCore-based purchasing model only<sup>1</sup>)
30
+
- Azure SQL elastic pools (vCore-based purchasing model only<sup>1</sup>)
31
+
- Azure SQL managed instances
32
+
- Azure SQL instance pools
33
+
- Azure Data Factory SSIS integration runtimes
34
+
- SQL Servers in Azure virtual machines
35
+
- SQL Servers in Azure virtual machines hosted in Azure dedicated host
36
+
37
+
<sup>1</sup>The DTU-based resources are not eligible for Azure Hybrid Benefit or HADR benefit.
38
+
39
+
# Launching the script
40
+
41
+
The script accepts the following command line parameters:
42
+
43
+
|**Parameter**|**Value**|**Description**|
44
+
|:--|:--|:--|
45
+
|-SubId|subscription_id *or* a file_name|Accepts a .csv file with the list of subscriptions<sup>2</sup>|
46
+
|-UseInRunbook||Must be specified when executed as a Runbook|
47
+
|-Server|[protocol:]server[instance_name][,port]|Required to save data to the database|
48
+
|-Database|database_name|Required to save data to the database|
49
+
|-Username|user_name|Required to save data to the database|
50
+
|-Password|password|Required to save data to the database|
51
+
|-FilePath|csv_file_name|Required to save data in a .csv format. Ignored if database parameters are specified|
52
+
53
+
<sup>2</sup>You can create a .csv file using the following command and then edit to remove the subscriptions you don't want to scan.
If both database parameters and *FilePath* are omitted, the script will write the results to a `.\sql-license-usage.csv` file. The file is created automatically. If the file already exists, the consecutive scans will append the results results to it. If the database parameters are specified, the data will be saved
58
+
59
+
27
60
>[!NOTE]
28
61
> - The usage data is a snapshot at the time of the script execution based on the size of the deployed SQL resources in vCores.
29
62
> - For IaaS workloads, such as SQL Server in Virtual Machines or SSIS integration runtimes, each vCPU is counted as one vCore.
30
63
> - For PaaS workloads, each vCore of Business Critical service tier is counted as one Enterprise vCore and each vCore of General Purpose service tier is counted as one Standard vCore.
64
+
> - The values AHB ECs and PAYG ECs are reserved for the future use and should be ignored
65
+
66
+
## Example 1
67
+
68
+
The following command will scan all the subscriptions in the account and save the results in `.\sql-license-usage.csv`
69
+
70
+
```PowerShell
71
+
.\sql-license-usage.ps1
72
+
```
73
+
74
+
## Example 2
75
+
76
+
The following command will scan the subscription `<sub_id>` and save the results in `<my_csv_file>` file.
The following command will scan all the subscriptions in the account and save the results in a SQL database `<db_name>` on a SQL Server instance `<sql_server_name>.database.windows.net`.
3. Run the script with a specific subscriptions ID or the file name as the parameter. The file should be used if you need to scan a subset of the subscriptions. If the parameter is not specified, the script will scan all the subscriptions in your account.
102
+
3. Run the script with a set of parameters that reflect your desired configuration.
45
103
46
104
```console
47
-
./sql-license-usage.ps1 <subscription ID> or <filename>.csv
105
+
./sql-license-usage.ps1 <parameters>
48
106
```
49
107
50
-
If the a file is specified, it must be a `.csv` file with the list of subscriptions. To create a file containing all subscriptions in your account, use the following command. You can then edit the file to remove the subscriptions you don't want to scan.
> - To paste the commands into the shell, use `Ctrl-Shift-V` on Windows or `Cmd-v` on MacOS.
57
110
> - The `curl`command will copy the script directly to the home folder associated with your Cloud Shell session.
58
111
59
112
# Tracking SQL license usage over time
60
113
61
-
You can track your license utilization over time by periodically running this script. Each new scan will add the results to `sql-license-usage.csv`, which you can use for reporting the license usage over time in Excel or other tools. To run this script on schedule using Azure automation, read [Create a PowerShell runbook tutorial](https://docs.microsoft.com/azure/automation/learn/automation-tutorial-runbook-textual-powershell).
114
+
You can track your license utilization over time by periodically running this script. To schedule automatic execution of the script, create a PowerShell runbook using an Azure Automation account. See the [Runbook tutorial](https://docs.microsoft.com/en-us/azure/automation/learn/automation-tutorial-runbook-textual-powershell) for the details of how to create a PowerShell runbook. Because the script accesses the resources across multiple subscriptions, the runbook must be able to authenticate using the Run As account that was automatically created when you created your Automation account. The logic required for the Runbooks is part of the script.
115
+
116
+
>[!IMPORTANT]
117
+
> - When running the script as a runbook, use a database to ensure that the results can be analyzed outside of the runbook.
118
+
> - You must specify a *-UseInRunbook* switch to ensure that the runbook is authenticated using the Run As account.
0 commit comments