Skip to content

Commit 7a710e8

Browse files
authored
Merge pull request #907 from anosov1960/master
Major update
2 parents 567d49a + b6f4cef commit 7a710e8

5 files changed

Lines changed: 280 additions & 182 deletions

File tree

DiscoverSql.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
# This function is to run on each VM to detect if SQL server is installed
4+
5+
[bool] $SqlInstalled = $false
6+
$regPath = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server'
7+
if (Test-Path $regPath) {
8+
$inst = (get-itemproperty $regPath).InstalledInstances
9+
$SqlInstalled = ($inst.Count -gt 0)
10+
}
11+
Write-Output $SqlInstalled

mysubscriptions.csv

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Id,Name,State,SubscriptionId,TenantId,HomeTenantId,ManagedByTenantIds,CurrentStorageAccountName,SubscriptionPolicies,ExtendedProperties,CurrentStorageAccount
2+
10a238d6-a139-46d0-818d-d091394072b6,geodr_m2_365640,Enabled,10a238d6-a139-46d0-818d-d091394072b6,72f988bf-86f1-41af-91ab-2d7cd011db47,72f988bf-86f1-41af-91ab-2d7cd011db47,System.String[],,"{
3+
""LocationPlacementId"": ""Internal_2014-09-01"",
4+
""QuotaId"": ""Internal_2014-09-01"",
5+
""SpendingLimit"": ""Off""
6+
}","System.Collections.Generic.Dictionary`2[System.String,System.String]",
7+
a5082b19-8a6e-4bc5-8fdd-8ef39dfebc39,ADS TINA Engineering,Enabled,a5082b19-8a6e-4bc5-8fdd-8ef39dfebc39,72f988bf-86f1-41af-91ab-2d7cd011db47,72f988bf-86f1-41af-91ab-2d7cd011db47,System.String[],,"{
8+
""LocationPlacementId"": ""Internal_2014-09-01"",
9+
""QuotaId"": ""Internal_2014-09-01"",
10+
""SpendingLimit"": ""Off""
11+
}","System.Collections.Generic.Dictionary`2[System.String,System.String]",
12+
741fd0f5-9cb8-442c-91c3-3ef4ca231c2a,Workload Insight dev/test subscription,Enabled,741fd0f5-9cb8-442c-91c3-3ef4ca231c2a,72f988bf-86f1-41af-91ab-2d7cd011db47,72f988bf-86f1-41af-91ab-2d7cd011db47,System.String[],,"{
13+
""LocationPlacementId"": ""Internal_2014-09-01"",
14+
""QuotaId"": ""Internal_2014-09-01"",
15+
""SpendingLimit"": ""Off""
16+
}","System.Collections.Generic.Dictionary`2[System.String,System.String]",

samples/manage/azure-hybrid-benefit/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ services: Azure SQL
33
platforms: Azure
44
author: anosov1960
55
ms.author: sashan
6-
ms.date: 2/2/2021
6+
ms.date: 3/5/2021
77
---
88

99
# Overview
1010

11-
This script provides a simple solution to analyze and track the consolidated utilization of SQL Server licenses by all of the SQL resources in a specific subscription or the entire account. By default, the script scans all subscriptions the user account has access to. 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.
11+
This script provides a simple solution to analyze and track the consolidated utilization of SQL Server licenses by all of the SQL resources in a specific subscription or the entire account. By default, the script scans all subscriptions the user account has access to. Alternatively, you can specify a single subscription or a .CSV file with a list of subscriptions.
1212

1313
| **Category** | **Description** |
1414
|:--|:--|
@@ -24,6 +24,8 @@ This script provides a simple solution to analyze and track the consolidated uti
2424
|HADR Ent vCores|Total vCores used by HADR replicas running SQL Server Enterprise edition|
2525
|Developer vCores|Total vCores used by SQL Server Developer edition|
2626
|Express vCores|Total vCores used by SQL Server Express edition|
27+
|Unregistered SQLVM vCores|Total vCores used by SQL Server VM that are not registered with SQL IaaS Agent Extension |
28+
|Unknown vCores|Total vCores used by Azure SQL Server resources with an unknown edition or service tier|
2729

2830
The following resources are in scope for the license utilization analysis:
2931
- Azure SQL databases (vCore-based purchasing model only)
@@ -38,7 +40,8 @@ The following resources are in scope for the license utilization analysis:
3840
> - The usage data is a snapshot at the time of the script execution based on the size of the deployed SQL resources in vCores.
3941
> - For IaaS workloads, such as SQL Server in Virtual Machines or SSIS integration runtimes, each vCPU is counted as one vCore.
4042
> - 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.
41-
> - In the DTU-based purchasing model, the SQL license cost is built into the individual SKU prices. These resources are not eligible for Azure Hybrid Benefit or HADR benefit, and therefore are not in scope of the tool.
43+
> - In the DTU-based purchasing model, the SQL license cost is built into the individual SKU prices. These resources are not eligible for Azure Hybrid Benefit or HADR benefit, and therefore are not in scope of the tool.
44+
> - You must be at least a *Reader* of each subscription you scan. However, to collect Unregistered SQLVM vCores you must be a subscription *Contributor* or *Owner*, otherwise this column will show a zero value.
4245
> - The values AHB ECs and PAYG ECs are reserved for the future use and should be ignored
4346
4447
# Launching the script
@@ -129,7 +132,7 @@ You can track your license utilization over time by running this script on sched
129132
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-hybrid-benefit/sql-license-usage.ps1 -o sql-license-usage.ps1
130133
```
131134
2. [Create a new automation account](https://ms.portal.azure.com/#create/Microsoft.AutomationAccount) or open an existing one.
132-
1. Select *Rus as accounts* in the **Account Settings** group, open the automatically created *Azure Run As Account* and note or copy the Display Name property. You must add this user to all the subscriptions you wish to scan with the *Reader* access role. See [Role assignment portal](https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal) for the instructions about role assignments.
135+
1. Select *Rus as accounts* in the **Account Settings** group, open the automatically created *Azure Run As Account* and note or copy the Display Name property. You must add this user to all the target subscriptions with at least a *Reader* access role. To collect the Unregistered SQLVM vCores, the user must be at least a *Contributor*. See [Role assignment portal](https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal) for the instructions about role assignments.
133136
1. Select *Credentials* in the **Shared resources** group and create a credential object with the database username and password. The script will use these to connect to the specified database to save the license utilization data.
134137
1. Select *Modules* in the **Shared resources** group and make sure your automation account have the following PowerShell modules installed. If not, add them from the Gallery.
135138
- Az.Accounts

0 commit comments

Comments
 (0)