Skip to content

Commit cab0ba5

Browse files
authored
Disabled AHB by default Azure#2493 (Azure#2627)
1 parent 233b3d4 commit cab0ba5

File tree

9 files changed

+307
-118
lines changed

9 files changed

+307
-118
lines changed

docs/CHANGELOG-v1.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,21 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
3434

3535
What's changed since v1.32.1:
3636

37+
- Updated rules:
38+
- Cognitive Services:
39+
- Relaxed `Azure.Cognitive.ManagedIdentity` to configurations that require managed identities by @BernieWhite.
40+
[#2559](https://github.com/Azure/PSRule.Rules.Azure/issues/2559)
41+
- Virtual Machine:
42+
- Checks for Azure Hybrid Benefit `Azure.VM.UseHybridUseBenefit` are not enabled by default by @BernieWhite.
43+
[#2493](https://github.com/Azure/PSRule.Rules.Azure/issues/2493)
44+
- To enable, set the `AZURE_VM_USE_HYBRID_USE_BENEFIT` option to `true`.
45+
- Virtual Network:
46+
- Added option for excluding subnets to `Azure.VNET.UseNSGs` by @BernieWhite.
47+
[#2572](https://github.com/Azure/PSRule.Rules.Azure/issues/2572)
48+
- To add a subnet exclusion, set the `AZURE_VNET_SUBNET_EXCLUDED_FROM_NSG` option.
3749
- General improvements:
3850
- Quality updates to rules and documentation by @BernieWhite.
3951
[#1772](https://github.com/Azure/PSRule.Rules.Azure/issues/1772)
40-
- Added option for excluding subnets to `Azure.VNET.UseNSGs` by @BernieWhite.
41-
[#2572](https://github.com/Azure/PSRule.Rules.Azure/issues/2572)
42-
- To add a subnet exclusion, set the `AZURE_VNET_SUBNET_EXCLUDED_FROM_NSG` option.
43-
- Relax `Azure.Cognitive.ManagedIdentity` to required configurations by @BernieWhite.
44-
[#2559](https://github.com/Azure/PSRule.Rules.Azure/issues/2559)
4552
- Engineering:
4653
- Bump xunit to v2.6.4.
4754
[#2618](https://github.com/Azure/PSRule.Rules.Azure/pull/2618)

docs/en/rules/Azure.VM.UseHybridUseBenefit.md

+93-42
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
2+
reviewed: 2024-01-03
23
severity: Awareness
34
pillar: Cost Optimization
4-
category: Pricing and billing model
5+
category: CO:05 Rate optimization
56
resource: Virtual Machine
67
online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.VM.UseHybridUseBenefit/
78
---
@@ -14,11 +15,31 @@ Use Azure Hybrid Benefit for applicable virtual machine (VM) workloads.
1415

1516
## DESCRIPTION
1617

17-
Azure Hybrid Benefit is a licensing benefit that helps you to reduce costs of running virtual machine (VM) workloads.
18+
The running cost of Virtual machine (VM) workloads in Azure is composed of several components, including:
19+
20+
- Compute usage for the VM size and image billed per second of run time, which may include:
21+
- Base compute rate for the VM size.
22+
- Software included on the VM image billed per second of run time, such as Windows Server or SQL Server.
23+
- Storage usage for the VM disks.
24+
- Network usage for data transfer in and out of the VM.
25+
- Usage of other supporting Azure resources, such as load balancers, public IP addresses, or log ingestion.
26+
- Licensing costs for other software installed on the VM.
27+
28+
Azure Hybrid Benefit is a licensing benefit that helps you to reduce your overall cost of ownership.
29+
With Azure Hybrid Benefit you to use your existing on-premises licenses to pay a reduced rate on Azure.
30+
31+
When Azure Hybrid Benefit enabled on supported VM images:
32+
33+
- The billing rate for the VM is adjusted to the base compute rate.
34+
- You must separately have eligible licenses, such as Windows Server or SQL Server because Azure does not include these anymore.
35+
36+
For additional information on Azure Hybrid Benefit, see the [Azure Hybrid Benefit FAQ][1].
37+
38+
[1]: https://azure.microsoft.com/pricing/hybrid-benefit/#faq
1839

1940
## RECOMMENDATION
2041

21-
Consider using Azure Hybrid Benefit for eligible workloads.
42+
Consider using Azure Hybrid Benefit for eligible virtual machine (VM) workloads.
2243

2344
## EXAMPLES
2445

@@ -34,44 +55,50 @@ For example:
3455

3556
```json
3657
{
37-
"type": "Microsoft.Compute/virtualMachines",
38-
"apiVersion": "2021-07-01",
39-
"name": "[parameters('name')]",
40-
"location": "[parameters('location')]",
41-
"properties": {
42-
"hardwareProfile": {
43-
"vmSize": "Standard_D2s_v3"
44-
},
45-
"osProfile": {
46-
"computerName": "[parameters('name')]",
47-
"adminUsername": "[parameters('adminUsername')]",
48-
"adminPassword": "[parameters('adminPassword')]"
49-
},
50-
"storageProfile": {
51-
"imageReference": {
52-
"publisher": "MicrosoftWindowsServer",
53-
"offer": "WindowsServer",
54-
"sku": "[parameters('sku')]",
55-
"version": "latest"
56-
},
57-
"osDisk": {
58-
"name": "[format('{0}-disk0', parameters('name'))]",
59-
"caching": "ReadWrite",
60-
"createOption": "FromImage"
61-
}
62-
},
63-
"licenseType": "Windows_Server",
64-
"networkProfile": {
65-
"networkInterfaces": [
66-
{
67-
"id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}-nic0', parameters('name')))]"
68-
}
69-
]
58+
"type": "Microsoft.Compute/virtualMachines",
59+
"apiVersion": "2023-09-01",
60+
"name": "[parameters('name')]",
61+
"location": "[parameters('location')]",
62+
"zones": [
63+
"1"
64+
],
65+
"properties": {
66+
"hardwareProfile": {
67+
"vmSize": "Standard_D2s_v3"
68+
},
69+
"osProfile": {
70+
"computerName": "[parameters('name')]",
71+
"adminUsername": "[parameters('adminUsername')]",
72+
"adminPassword": "[parameters('adminPassword')]"
73+
},
74+
"storageProfile": {
75+
"imageReference": {
76+
"publisher": "MicrosoftWindowsServer",
77+
"offer": "WindowsServer",
78+
"sku": "[parameters('sku')]",
79+
"version": "latest"
80+
},
81+
"osDisk": {
82+
"name": "[format('{0}-disk0', parameters('name'))]",
83+
"caching": "ReadWrite",
84+
"createOption": "FromImage",
85+
"managedDisk": {
86+
"storageAccountType": "Premium_LRS"
7087
}
88+
}
7189
},
72-
"dependsOn": [
73-
"[resourceId('Microsoft.Network/networkInterfaces', format('{0}-nic0', parameters('name')))]"
74-
]
90+
"licenseType": "Windows_Server",
91+
"networkProfile": {
92+
"networkInterfaces": [
93+
{
94+
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
95+
}
96+
]
97+
}
98+
},
99+
"dependsOn": [
100+
"[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
101+
]
75102
}
76103
```
77104

@@ -86,9 +113,12 @@ To deploy VMs that pass this rule:
86113
For example:
87114

88115
```bicep
89-
resource vm 'Microsoft.Compute/virtualMachines@2021-07-01' = {
116+
resource vm_with_benefit 'Microsoft.Compute/virtualMachines@2023-09-01' = {
90117
name: name
91118
location: location
119+
zones: [
120+
'1'
121+
]
92122
properties: {
93123
hardwareProfile: {
94124
vmSize: 'Standard_D2s_v3'
@@ -109,6 +139,9 @@ resource vm 'Microsoft.Compute/virtualMachines@2021-07-01' = {
109139
name: '${name}-disk0'
110140
caching: 'ReadWrite'
111141
createOption: 'FromImage'
142+
managedDisk: {
143+
storageAccountType: 'Premium_LRS'
144+
}
112145
}
113146
}
114147
licenseType: 'Windows_Server'
@@ -129,8 +162,26 @@ resource vm 'Microsoft.Compute/virtualMachines@2021-07-01' = {
129162
az vm update -n '<name>' -g '<resource_group>' --set licenseType=Windows_Server
130163
```
131164

165+
### NOTES
166+
167+
This rule is not processed by default.
168+
To enable this rule, set the `AZURE_VM_USE_AZURE_HYBRID_BENEFIT` configuration value to `true`.
169+
170+
For example:
171+
172+
```yaml title="ps-rule.yaml"
173+
configuration:
174+
AZURE_VM_USE_AZURE_HYBRID_BENEFIT: true
175+
```
176+
177+
The following limitations currently apply:
178+
179+
- This rule only applies to Azure Hybrid Benefit for Windows VMs.
180+
Linux VM images are ignored.
181+
132182
## LINKS
133183
134-
- [Design review checklist for Cost Optimization](https://learn.microsoft.com/azure/well-architected/cost-optimization/checklist)
135-
- [Azure Hybrid Benefit FAQ](https://azure.microsoft.com/pricing/hybrid-benefit/faq/)
184+
- [CO:05 Rate optimization](https://learn.microsoft.com/azure/well-architected/cost-optimization/get-best-rates)
185+
- [Azure Hybrid Benefit FAQ](https://azure.microsoft.com/pricing/hybrid-benefit/#faq)
136186
- [Explore Azure Hybrid Benefit for Windows VMs](https://learn.microsoft.com/azure/virtual-machines/windows/hybrid-use-benefit-licensing)
187+
- [Azure deployment reference](https://learn.microsoft.com/azure/templates/microsoft.compute/virtualmachines)

docs/examples-vm.bicep

+46-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,50 @@ param sku string
2323
@description('A reference to the VNET subnet where the VM will be deployed.')
2424
param subnetId string
2525

26-
// An example basic VM
27-
resource vm1 'Microsoft.Compute/virtualMachines@2023-07-01' = {
26+
// An example virtual machine.
27+
resource vm 'Microsoft.Compute/virtualMachines@2023-09-01' = {
28+
name: name
29+
location: location
30+
zones: [
31+
'1'
32+
]
33+
properties: {
34+
hardwareProfile: {
35+
vmSize: 'Standard_D2s_v3'
36+
}
37+
osProfile: {
38+
computerName: name
39+
adminUsername: adminUsername
40+
adminPassword: adminPassword
41+
}
42+
storageProfile: {
43+
imageReference: {
44+
publisher: 'MicrosoftWindowsServer'
45+
offer: 'WindowsServer'
46+
sku: sku
47+
version: 'latest'
48+
}
49+
osDisk: {
50+
name: '${name}-disk0'
51+
caching: 'ReadWrite'
52+
createOption: 'FromImage'
53+
managedDisk: {
54+
storageAccountType: 'Premium_LRS'
55+
}
56+
}
57+
}
58+
networkProfile: {
59+
networkInterfaces: [
60+
{
61+
id: nic.id
62+
}
63+
]
64+
}
65+
}
66+
}
67+
68+
// An example virtual machine with Azure Hybrid Benefit.
69+
resource vm_with_benefit 'Microsoft.Compute/virtualMachines@2023-09-01' = {
2870
name: name
2971
location: location
3072
zones: [
@@ -71,7 +113,8 @@ resource vm1 'Microsoft.Compute/virtualMachines@2023-07-01' = {
71113
@sys.description('The name of the resource.')
72114
param nicName string
73115

74-
resource nic 'Microsoft.Network/networkInterfaces@2023-05-01' = {
116+
// An example network interface
117+
resource nic 'Microsoft.Network/networkInterfaces@2023-06-01' = {
75118
name: nicName
76119
location: location
77120
properties: {

docs/examples-vm.json

+49-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"metadata": {
55
"_generator": {
66
"name": "bicep",
7-
"version": "0.23.1.45101",
8-
"templateHash": "1366791398259070498"
7+
"version": "0.24.24.22086",
8+
"templateHash": "8240160405856325456"
99
}
1010
},
1111
"parameters": {
@@ -58,7 +58,52 @@
5858
"resources": [
5959
{
6060
"type": "Microsoft.Compute/virtualMachines",
61-
"apiVersion": "2023-07-01",
61+
"apiVersion": "2023-09-01",
62+
"name": "[parameters('name')]",
63+
"location": "[parameters('location')]",
64+
"zones": [
65+
"1"
66+
],
67+
"properties": {
68+
"hardwareProfile": {
69+
"vmSize": "Standard_D2s_v3"
70+
},
71+
"osProfile": {
72+
"computerName": "[parameters('name')]",
73+
"adminUsername": "[parameters('adminUsername')]",
74+
"adminPassword": "[parameters('adminPassword')]"
75+
},
76+
"storageProfile": {
77+
"imageReference": {
78+
"publisher": "MicrosoftWindowsServer",
79+
"offer": "WindowsServer",
80+
"sku": "[parameters('sku')]",
81+
"version": "latest"
82+
},
83+
"osDisk": {
84+
"name": "[format('{0}-disk0', parameters('name'))]",
85+
"caching": "ReadWrite",
86+
"createOption": "FromImage",
87+
"managedDisk": {
88+
"storageAccountType": "Premium_LRS"
89+
}
90+
}
91+
},
92+
"networkProfile": {
93+
"networkInterfaces": [
94+
{
95+
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
96+
}
97+
]
98+
}
99+
},
100+
"dependsOn": [
101+
"[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
102+
]
103+
},
104+
{
105+
"type": "Microsoft.Compute/virtualMachines",
106+
"apiVersion": "2023-09-01",
62107
"name": "[parameters('name')]",
63108
"location": "[parameters('location')]",
64109
"zones": [
@@ -104,7 +149,7 @@
104149
},
105150
{
106151
"type": "Microsoft.Network/networkInterfaces",
107-
"apiVersion": "2023-05-01",
152+
"apiVersion": "2023-06-01",
108153
"name": "[parameters('nicName')]",
109154
"location": "[parameters('location')]",
110155
"properties": {

0 commit comments

Comments
 (0)