
Previous week, we were doing our quarterly Azure Security Assessment when I found that a pretty old VM disk snapshot is sitting there and costing us some decent euros.
I immmediately messaged my manager so that we can look into this:
Digging into another subscription, I did found a database named ‘test’ which had accumulated 208.04 eurors at a timespan of 30 days.
At the time of writing of this article, We have 10 subscriptions in Azure, each containing a considerable amount of resources including Networking resources such as VNets, Subnets, Private Endpoints, NSGs, as well as PaaS services such as Container Apps, Databases , KeyVaults and Storage Accounts.
These subscriptions have been shared with members of different engineering teams, so Keeping track of every resource someone creates, modifies or updates is quite challenging.
Although we have a process in place that require team members to create Infrastructure components using Terraform, raise a PR and have it reviewed before that TF code gets applied via Ci/CD pipeline.
Still it happens most of the time that a resource gets created as part of a POC, or as an experiment and the person forgets to delete that later on, resulting in unnecesary costs and security concerns. Take an example of “test” database from above screenshot.
Understanding Azure Security Attack Surface
Over time, we have learned that it’s not possible to have a perfect infrastructure in place.
New resources, new subscriptions would be getting created regularly, people would be creating throwaway resources and they will be “forgetting” the cleanup. So we accepted this reality and planned an Azure Infrastructure Assessment Activity every quarter.
On a very high level, the purpose of this activity was to answer following three questions:
- Which resources exists in Azure ? And why are they required ?
- Are there any security mis-configurations that we can fix ?
- Are there any optimization opportunities that can help us save costs ?
‘Security’ was our biggest concern. So we start by building an inventory of common resources that exists in almost every subscription.
We started by building an Excel sheet in which we divided Azure resources across ‘categories’ and under categories we have the actual resources. For example, ‘Network & Connectivity’ is our biggest category having resource types VNets, Subnets, Private Endpoints, NSGs, NAT gateway and public IPs.
Against each resource we wrote a couple of “Audit questions”.
Every quarter, our goal is to answer these questions by looking at the current state of infra, finding mis-configurations and vulnerabilities, assessing their severity, and taking corrective action where necessary.
These Audit Questions became foundations of our Azure Security Assessment.
You can find the Link of Audit Sheet Here.
Auditing Network & Connectivity
In order to answer the questions under “Network and Connectivity” category, we need to investigate and come up with certain findings so we can populate the sheet with Accurate data.
- To identify how many VNet peerings exist, navigate to the specific VNet > Peerings tab.
- Check that each peering has a Fully Synchronized status. More importantly, verify whether the connection is still required. An old peering between networks that no longer communicate is worth investigating.
- To Check how many Subnets we have, We can go to the VNet > Subnets and check if all subnets are required.
Record the number of subnets and investigate whether each one is still required. Also review their address ranges and associated Network Security Groups (NSGs).
- Similarly, we can edit a Subnet > Check Outbound access and record our findings to question “Private subnets enabled for subnets not requiring Outbound access?”
For subnets that don’t require outbound internet connectivity, make sure that Enable private subnet (no default outbound access) is enabled.

You can see that looking up each resource’s config is very manual process and prone to human error.
So we decided to use “Azure Resource Graph explorer” to pull the necessary config and data using KQL queries.
Investigate using KQL queries:
To answer the same VNet peering question, we can use the following KQL query:
resources | where type =~ 'microsoft.network/virtualnetworks' | where subscriptionId == '<your-subscription-id>' | mv-expand peering = properties.virtualNetworkPeerings | where isnotempty(peering) | extend remoteVnetId = tostring(peering.properties.remoteVirtualNetwork.id) | project vnetName = name, resourceGroup, location, peeringName = tostring(peering.name), peeringState = tostring(peering.properties.peeringState), // Connected / Initiated / Disconnected syncLevel = tostring(peering.properties.peeringSyncLevel), // FullyInSync / LocalNotInSync / ... remoteVnetName = tostring(split(remoteVnetId, '/')[8]), remoteSubscriptionId = tostring(split(remoteVnetId, '/')[2]), allowVnetAccess = tobool(peering.properties.allowVirtualNetworkAccess), allowForwardedTraffic = tobool(peering.properties.allowForwardedTraffic), allowGatewayTransit = tobool(peering.properties.allowGatewayTransit), useRemoteGateways = tobool(peering.properties.useRemoteGateways) | order by vnetName asc Similarly, we can answer “which storage accounts allow shared key access?” using below KQL query:
resources | where type =~ 'microsoft.storage/storageaccounts' | where subscriptionId == '<your-subscription-id>' | extend sharedKeyRaw = properties.allowSharedKeyAccess | extend sharedKeyAllowed = iff(isnull(sharedKeyRaw), true, tobool(sharedKeyRaw)) | where sharedKeyAllowed == true | project name, resourceGroup, location, kind, sku = tostring(sku.name), sharedKeyAllowed, explicitlySet = isnotnull(sharedKeyRaw), publicNetworkAccess = tostring(properties.publicNetworkAccess), defaultToOAuth = tobool(properties.defaultToOAuthAuthentication), minimumTlsVersion = tostring(properties.minimumTlsVersion) | order by name asc it will return a list of storage accounts which are non-compliant. We can record them in the Excel sheet against Subscription and Resource group.
Notice how we handle SharedKeyAllowed.
When this property is false, Shared Key authorization is disabled. However, when it is true or null, Shared Key authorization is allowed. We can review these against our security baseline and identify which ones requires turning off sharedKeyAccess.
From Manual Audits to Azure-Audit
Now we have seen that we can investigate our Azure resources using both the Azure Portal and using KQL queries. KQL queries make it much simpler and straight-forward, but even with KQL queries, an Engineer has to put effort to interpret results and manually record that in the Excel Sheet.
Imagine doing this across multiple subscriptions and the Assessment Activity will itself become a Sprint in Jira.
That’s the reason I built Azure-Audit.
It’s an open-source tool that automates the process of investigating Azure subscriptions against a structured set of security and optimization checks.
Instead of manually navigating resources and maintaining separate queries, we can run an assessment and get a consolidated view of the findings, organized by resource group.

The reason why I built this is because I want to see 3 things in a pretty straight-forward way.
Security: What is the security posture of my Azure resources?
Cost: Which orphaned or idle resources are still costing us money?
Networking: What does our network configuration look like at a high level?
Azure-Audit does exactly these 3 things in a simple way. That’s it. I didn’t want another tool overloaded with fancy features. I wanted something that could answer these three questions without making the auditing process more complicated.
Getting started is simple. Clone the repository, authenticate using Azure CLI, and run it locally. It has no Cloud-backend so it’s safe to use.
Another good things about this is the ‘Reporting’. Instead of tracking each finding manually in the Excel sheet, I can get the same perfectly formatted excel sheet with a click of a button.
This makes it much easier to share assessment results with the team and management without spending additional time preparing reports.
So now, our process to conduct the Assessment Activity looks like this:
- Run the tool
- Get the Assessment
- Present in front of Manager
- Have the fixes and Optimizations applied
- Repeat the same in next quarter
Final Thoughts:
Our Cloud infrastructure was constantly changing. New resources being deployed, temporary environments being created, configurations evolve, and sometimes resources are simply forgotten after creation.
Having Terraform, CI/CD pipelines, and infrastructure reviews is important, but they don’t guarantee that the actual Azure environment remains secure and optimized.
That’s why regular assessments matter.
You don’t need an expensive platform or a complicated process to start. I would love for other Azure engineers to try Azure-Audit, explore the code, and contribute.











