Skip to content

Commit e75698b

Browse files
rod-reisRodrigo Reis Santos (AZURE)Copilot
authored
fix: Rosanto - Quality Updates - May/2025 (#739)
Co-authored-by: Rodrigo Reis Santos (AZURE) <Rodrigo.REIS@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d7761e7 commit e75698b

26 files changed

Lines changed: 131 additions & 256 deletions
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// Azure Resource Graph Query
2-
// Find all Virtual Machines not associated with a Capacity Reservation, and provide details for Capacity Reservation like vmSize, location, and zone.
3-
resources
4-
| where type =~ 'Microsoft.Compute/virtualMachines'
5-
| where isnull(properties.capacityReservation)
6-
| extend zoneValue = iff(isnull(zones), "null", zones)
7-
| project recommendationId = "302fda08-ee65-4fbe-a916-6dc0b33169c4", name, id, tags, param1 = strcat("VmSize: ", properties.hardwareProfile.vmSize), param2 = strcat("Location: ", location), param3 = strcat("Zone: ", zoneValue)
2+
// Find Virtual Machine capacity reservations and their associated properties
3+
advisorresources
4+
| where properties.recommendationTypeId =~ '1670c0af-6536-4cbf-872f-152c91a51a80' // RecommendationID from Advisor
5+
| mv-expand resId = properties.resourceMetadata.resourceId
6+
| extend resId = tolower(tostring(resId))
7+
| project recId = properties.recommendationTypeId, resId
8+
| join kind=leftouter (
9+
resources
10+
| extend id = tolower(tostring(id))
11+
| project id, name, tags, location, properties
12+
) on $left.resId == $right.id
13+
| project recommendationId = "302fda08-ee65-4fbe-a916-6dc0b33169c4", name , id = resId, tags,param1 = properties.hardwareProfile.vmSize, param2 = location

azure-resources/Compute/virtualMachines/kql/52ab9e5c-eec0-3148-8bd7-b6dd9e1be870.kql

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
// Azure Resource Graph Query
2-
// Find VMS that do not have maintenance configuration assigned
3-
Resources
4-
| extend resourceId = tolower(id)
5-
| project name, location, type, id, tags, resourceId, properties
2+
// Find VMs on Dedicated Hosts or using Isolated SKUs (via substring match) that do NOT have a maintenance configuration assigned
3+
resources
64
| where type =~ 'Microsoft.Compute/virtualMachines'
5+
| extend
6+
resourceId = tolower(id),
7+
hostId = tostring(properties.host.id),
8+
hostGroupId = tostring(properties.hostGroup.id),
9+
vmSize = tostring(properties.hardwareProfile.vmSize)
10+
| where
11+
// 1) Dedicated Host association
12+
isnotempty(hostId) or isnotempty(hostGroupId)
13+
// 2) OR any of the "isolated" substrings
14+
or (
15+
vmSize contains "i_" or
16+
vmSize contains "is_" or
17+
vmSize contains "id_" or
18+
vmSize contains "ids_" or
19+
vmSize contains "idms_" or
20+
vmSize contains "ims_" or
21+
vmSize contains "G5" or
22+
vmSize contains "GS5" or
23+
vmSize contains "F72s_" or
24+
vmSize contains "M128ms"
25+
)
726
| join kind=leftouter (
8-
maintenanceresources
9-
| where type =~ "microsoft.maintenance/configurationassignments"
10-
| project planName = name, type, maintenanceProps = properties
11-
| extend resourceId = tostring(maintenanceProps.resourceId)
27+
resources
28+
| where type =~ 'microsoft.maintenance/configurationassignments'
29+
| extend resourceId = tolower(tostring(properties.resourceId))
30+
| project resourceId, maintenanceProps = properties
1231
) on resourceId
1332
| where isnull(maintenanceProps)
14-
| project recommendationId = "52ab9e5c-eec0-3148-8bd7-b6dd9e1be870",name, id, tags
33+
| project
34+
recommendationId = "52ab9e5c-eec0-3148-8bd7-b6dd9e1be870",
35+
name,
36+
id,
37+
tags
1538
| order by id asc
16-
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
// cannot-be-validated-with-arg
1+
// Azure Resource Graph Query
2+
// Find all VM NICs that have Accelerated Networking enabled
3+
resources
4+
| where type =~ 'Microsoft.Compute/virtualMachines'
5+
| mv-expand nic = properties.networkProfile.networkInterfaces
6+
| project name, id, tags, lowerCaseNicId = tolower(nic.id), vmSize = tostring(properties.hardwareProfile.vmSize)
7+
| join kind = inner (
8+
resources
9+
| where type =~ 'Microsoft.Network/networkInterfaces'
10+
| where properties.enableAcceleratedNetworking == true
11+
| project nicName = split(id, "/")[8], lowerCaseNicId = tolower(id)
12+
)
13+
on lowerCaseNicId
14+
| summarize nicNames = make_set(nicName) by name, id, tostring(tags), vmSize
15+
| extend param2 = strcat("NicName: ", strcat_array(nicNames, ", ")), param3 = strcat("VMSize: ", vmSize)
16+
| project recommendationId = "dfedbeb1-1519-fc47-86a5-52f96cf07105", name, id, tags, param1="This machine has AccelNet enabled, but it is not possible to confirm if the GuestOS drivers are Up-to-Date.", param2,param3
17+
| order by id asc
218

azure-resources/Compute/virtualMachines/recommendations.yaml

Lines changed: 4 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,6 @@
117117
- name: What is the Azure Backup service?
118118
url: "https://learn.microsoft.com/azure/backup/backup-overview"
119119

120-
- description: Review VMs in stopped state
121-
aprlGuid: 98b334c0-8578-6046-9e43-b6e8fce6318e
122-
recommendationTypeId: null
123-
recommendationControl: Governance
124-
recommendationImpact: Low
125-
recommendationResourceType: Microsoft.Compute/virtualMachines
126-
recommendationMetadataState: Disabled
127-
longDescription: |
128-
Azure Virtual Machines (VM) instances have various states, like provisioning and power states. A non-running VM may indicate issues or it being unnecessary, suggesting removal could help cut costs.
129-
potentialBenefits: Reduce costs by removing unused VMs
130-
pgVerified: true
131-
automationAvailable: true
132-
tags: []
133-
learnMoreLink:
134-
- name: States and billing status of Azure Virtual Machines
135-
url: "https://learn.microsoft.com/azure/virtual-machines/states-billing?context=%2Ftroubleshoot%2Fazure%2Fvirtual-machines%2Fcontext%2Fcontext#power-states-and-billing"
136-
137120
- description: Enable Accelerated Networking (AccelNet)
138121
aprlGuid: dfedbeb1-1519-fc47-86a5-52f96cf07105
139122
recommendationTypeId: null
@@ -162,46 +145,12 @@
162145
When Accelerated Networking is enabled, the default Azure VNet interface in GuestOS is swapped for a Mellanox, and its driver comes from a 3rd party. Marketplace images have the latest Mellanox drivers, but post-deployment, updating the driver is the user's responsibility.
163146
potentialBenefits: Enhanced VM network efficiency
164147
pgVerified: true
165-
automationAvailable: false
148+
automationAvailable: true
166149
tags: []
167150
learnMoreLink:
168151
- name: Accelerated Networking (AccelNet) overview
169152
url: "https://learn.microsoft.com/azure/virtual-network/accelerated-networking-overview"
170153

171-
- description: VMs should not have a Public IP directly associated
172-
aprlGuid: 1f629a30-c9d0-d241-82ee-6f2eb9d42cb4
173-
recommendationTypeId: null
174-
recommendationControl: Security
175-
recommendationImpact: Medium
176-
recommendationResourceType: Microsoft.Compute/virtualMachines
177-
recommendationMetadataState: Disabled
178-
longDescription: |
179-
For outbound internet connectivity of Virtual Machines, using NAT Gateway or Azure Firewall is recommended to enhance security and service resilience, thanks to their higher availability and SNAT ports.
180-
potentialBenefits: Enhanced security and service resiliency
181-
pgVerified: true
182-
automationAvailable: true
183-
tags: []
184-
learnMoreLink:
185-
- name: Use Source Network Address Translation (SNAT) for outbound connections
186-
url: "https://learn.microsoft.com/azure/load-balancer/load-balancer-outbound-connections"
187-
188-
- description: VM network interfaces and associated subnets both have a Network Security Group associated
189-
aprlGuid: 82b3cf6b-9ae2-2e44-b193-10793213f676
190-
recommendationTypeId: null
191-
recommendationControl: Security
192-
recommendationImpact: Low
193-
recommendationResourceType: Microsoft.Compute/virtualMachines
194-
recommendationMetadataState: Disabled
195-
longDescription: |
196-
Unless you have a specific reason, it's advised to associate a network security group to a subnet or a network interface, but not both, to avoid unexpected communication issues and troubleshooting due to potential rule conflicts between the two associations.
197-
potentialBenefits: Reduces communication problems
198-
pgVerified: true
199-
automationAvailable: true
200-
tags: []
201-
learnMoreLink:
202-
- name: How network security groups filter network traffic
203-
url: "https://learn.microsoft.com/azure/virtual-network/network-security-group-how-it-works#intra-subnet-traffic"
204-
205154
- description: IP Forwarding should only be enabled for Network Virtual Appliances
206155
aprlGuid: 41a22a5e-5e08-9647-92d0-2ffe9ef1bdad
207156
recommendationTypeId: null
@@ -219,23 +168,6 @@
219168
- name: Enable or disable IP forwarding
220169
url: "https://learn.microsoft.com/azure/virtual-network/virtual-network-network-interface?tabs=network-interface-portal#enable-or-disable-ip-forwarding"
221170

222-
- description: Customer DNS Servers should be configured in the Virtual Network level
223-
aprlGuid: 1cf8fe21-9593-1e4e-966b-779a294c0d30
224-
recommendationTypeId: null
225-
recommendationControl: OtherBestPractices
226-
recommendationImpact: Low
227-
recommendationResourceType: Microsoft.Compute/virtualMachines
228-
recommendationMetadataState: Disabled
229-
longDescription: |
230-
Configure the DNS Server at the Virtual Network level to prevent any inconsistency across the environment.
231-
potentialBenefits: Ensures DNS consistency
232-
pgVerified: true
233-
automationAvailable: true
234-
tags: []
235-
learnMoreLink:
236-
- name: Name resolution for resources in Azure virtual networks
237-
url: "https://learn.microsoft.com/azure/virtual-network/virtual-networks-name-resolution-for-vms-and-role-instances"
238-
239171
- description: Network access to the VM disk should be set to Disable public access and enable private access
240172
aprlGuid: 70b1d2be-e6c4-b54e-9959-b1b690f9e485
241173
recommendationTypeId: null
@@ -253,40 +185,6 @@
253185
- name: Restrict import/export access for managed disks using Azure Private Link
254186
url: "https://learn.microsoft.com/azure/virtual-machines/disks-enable-private-links-for-import-export-portal"
255187

256-
- description: Ensure that your VMs are compliant with Azure Policies
257-
aprlGuid: c42343ae-2712-2843-a285-3437eb0b28a1
258-
recommendationTypeId: null
259-
recommendationControl: Governance
260-
recommendationImpact: Low
261-
recommendationResourceType: Microsoft.Compute/virtualMachines
262-
recommendationMetadataState: Disabled
263-
longDescription: |
264-
Keeping your virtual machine (VM) secure is crucial for the applications you run. This involves using various Azure services and features to ensure secure access to your VMs and the secure storage of your data, aiming for overall security of your VM and applications.
265-
potentialBenefits: Secure VMs and applications
266-
pgVerified: true
267-
automationAvailable: true
268-
tags: []
269-
learnMoreLink:
270-
- name: Policy-driven governance
271-
url: "https://learn.microsoft.com/azure/cloud-adoption-framework/ready/landing-zone/design-principles#policy-driven-governance"
272-
273-
- description: Virtual Machines should have Azure Disk Encryption or EncryptionAtHost enabled
274-
aprlGuid: f0a97179-133a-6e4f-8a49-8a44da73ffce
275-
recommendationTypeId: a40cc620-e72c-fdf4-c554-c6ca2cd705c0
276-
recommendationControl: Security
277-
recommendationImpact: High
278-
recommendationResourceType: Microsoft.Compute/virtualMachines
279-
recommendationMetadataState: Disabled
280-
longDescription: |
281-
Consider enabling Azure Disk Encryption (ADE) for encrypting Azure VM disks using DM-Crypt (Linux) or BitLocker (Windows). Additionally, consider Encryption at host and Confidential disk encryption for enhanced data security.
282-
potentialBenefits: Enhances data security and integrity
283-
pgVerified: true
284-
automationAvailable: true
285-
tags: []
286-
learnMoreLink:
287-
- name: Overview of managed disk encryption options
288-
url: "https://learn.microsoft.com/azure/virtual-machines/disk-encryption-overview"
289-
290188
- description: Enable VM Insights
291189
aprlGuid: b72214bb-e879-5f4b-b9cd-642db84f36f4
292190
recommendationTypeId: null
@@ -304,28 +202,11 @@
304202
- name: Overview of VM insights
305203
url: "https://learn.microsoft.com/azure/azure-monitor/vm/vminsights-overview"
306204

307-
- description: Configure monitoring for all Azure Virtual Machines
308-
aprlGuid: 4a9d8973-6dba-0042-b3aa-07924877ebd5
309-
recommendationTypeId: null
310-
recommendationControl: MonitoringAndAlerting
311-
recommendationImpact: Low
312-
recommendationResourceType: Microsoft.Compute/virtualMachines
313-
recommendationMetadataState: Disabled
314-
longDescription: |
315-
Azure Monitor Metrics automatically receives platform metrics, but platform logs, which offer detailed diagnostics and auditing for resources and their Azure platform, need to be manually routed for collection.
316-
potentialBenefits: Enhanced diagnostics and auditing capability
317-
pgVerified: true
318-
automationAvailable: true
319-
tags: []
320-
learnMoreLink:
321-
- name: Azure Monitor Agent overview
322-
url: "https://learn.microsoft.com/azure/azure-monitor/agents/agents-overview"
323-
324-
- description: Use maintenance configurations for the VMs
205+
- description: Use maintenance configurations for the Dedicated and/or Isolated VM SKUs
325206
aprlGuid: 52ab9e5c-eec0-3148-8bd7-b6dd9e1be870
326207
recommendationTypeId: null
327208
recommendationControl: HighAvailability
328-
recommendationImpact: High
209+
recommendationImpact: Medium
329210
recommendationResourceType: Microsoft.Compute/virtualMachines
330211
recommendationMetadataState: Active
331212
longDescription: |
@@ -372,7 +253,7 @@
372253
- name: Disk type comparison and decision tree
373254
url: "https://learn.microsoft.com/azure/virtual-machines/disks-types#disk-type-comparison"
374255

375-
- description: Use Azure Boost VMs for Maintenance sensitive workload
256+
- description: Use Azure Boost VMs for Maintenance sensitive workload VMs
376257
aprlGuid: 9ab499d8-8844-424d-a2d4-8f53690eb8f8
377258
recommendationTypeId: null
378259
recommendationControl: HighAvailability

azure-resources/ContainerService/managedClusters/kql/005ccbbd-aeab-46ef-80bd-9bd4479412ec.kql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ resources
66
| extend taints = tostring(parse_json(agentPoolProfile.nodeTaints))
77
| extend nodePool = tostring(parse_json(agentPoolProfile.name))
88
| where taints !has "CriticalAddonsOnly=true:NoSchedule" and agentPoolProfile.minCount < 2
9-
| project recommendationId="005ccbbd-aeab-46ef-80bd-9bd4479412ec", id, name, param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)
10-
9+
| project recommendationId="005ccbbd-aeab-46ef-80bd-9bd4479412ec", name=nodePool, id=strcat(id,"/agentPools/",nodePool), tags,param1=strcat("nodePoolName: ", nodePool), param2=strcat("nodePoolMinNodeCount: ", agentPoolProfile.minCount)

azure-resources/ContainerService/managedClusters/kql/0611251f-e70f-4243-8ddd-cfe894bec2e7.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
resources
44
| where type =~ "Microsoft.ContainerService/managedClusters"
55
| where sku.tier !in~ ("Standard", "Premium")
6-
| project recommendationId = "0611251f-e70f-4243-8ddd-cfe894bec2e7", id, name, tags, param1 = strcat("skuName: ", sku.name), param2 = strcat("skuTier: ", sku.tier)
6+
| project recommendationId = "0611251f-e70f-4243-8ddd-cfe894bec2e7", name,id, tags, param1 = strcat("skuName: ", sku.name), param2 = strcat("skuTier: ", sku.tier)

azure-resources/ContainerService/managedClusters/kql/26ebaf1f-c70d-4ebd-8641-4b60a0ce0094.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ PolicyResources
1313
| where type =~ 'Microsoft.ContainerService/managedClusters'
1414
| project id, name
1515
) on id
16-
| project recommendationId="26ebaf1f-c70d-4ebd-8641-4b60a0ce0094", id, name, param1=strcat("numNonCompliantAlerts: ", count_)
16+
| project recommendationId="26ebaf1f-c70d-4ebd-8641-4b60a0ce0094", name,id,param1=strcat("numNonCompliantAlerts: ", count_)

azure-resources/ContainerService/managedClusters/kql/4f63619f-5001-439c-bacb-8de891287727.kql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Azure Resource Graph Query
2-
// Returns AKS clusters that do not have any availability zones enabled or only use a single zone
2+
// Returns AKS clusters Node Pools that do not have any availability zones enabled or only use a single zone
33
resources
44
| where type =~ "Microsoft.ContainerService/managedClusters"
55
| where location in~ ("australiaeast", "brazilsouth", "canadacentral", "centralindia", "centralus", "eastasia", "eastus", "eastus2", "francecentral", "germanywestcentral", "israelcentral", "italynorth", "japaneast", "japanwest", "koreacentral", "mexicocentral", "newzealandnorth", "northeurope", "norwayeast", "polandcentral", "qatarcentral", "southafricanorth", "southcentralus", "southeastasia", "spaincentral", "swedencentral", "switzerlandnorth", "uaenorth", "uksouth", "westeurope", "westus2", "westus3", "usgovvirginia", "chinanorth3")
@@ -10,8 +10,8 @@ resources
1010
| where numOfAvailabilityZones < 2
1111
| project
1212
recommendationId = "4f63619f-5001-439c-bacb-8de891287727",
13-
id,
14-
name,
13+
name=pool.name,
14+
id=strcat(id,"/agentPools/",pool.name),
1515
tags,
1616
param1 = strcat("NodePoolName: ", pool.name),
1717
param2 = strcat("Mode: ", pool.mode),

azure-resources/ContainerService/managedClusters/kql/5ee083cd-6ac3-4a83-8913-9549dd36cf56.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ resources
1212
| where hasCriticalAddonsOnly
1313
| project
1414
recommendationId="5ee083cd-6ac3-4a83-8913-9549dd36cf56",
15-
id,
1615
name,
16+
id,
1717
tags,
1818
param1=strcat("nodepoolName: ", nodePool)

azure-resources/ContainerService/managedClusters/kql/5f3cbd68-692a-4121-988c-9770914859a9.kql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ resources
44
| where type == "microsoft.containerservice/managedclusters"
55
| extend gitops = tostring (parse_json(properties.addOnProfiles.gitops.enabled))
66
| where isempty(gitops)
7-
| project recommendationId="5f3cbd68-692a-4121-988c-9770914859a9", id, name, tags, param1=strcat("gitopsEnabled: ", "false")
7+
| project recommendationId="5f3cbd68-692a-4121-988c-9770914859a9", name, id, tags, param1=strcat("gitopsEnabled: ", "false")
88

0 commit comments

Comments
 (0)