Track IP addresses consumption with Azure Application Insights - Part 2
Introduction
In part 1 we saw how to send a custom event telemetry to an Azure Application Insights instance through PowerShell.
We did track our Azure Virtual Network IP addresses consumption, we will now automate this tracking every 30 minutes through a Timer Trigger Azure Function App.
The Azure Function will be deployed through Bicep. Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. According to Microsoft documentation Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.
Prerequisites
Azure account
Before you begin, you must have an Azure account with an active subscription. Create an account for free.
Code repository
Download the sample code repository, run the following command in your local terminal window:
Review the Bicep files and create your environment
Bicep file to create the Azure Function App
The following four Azure resources are created by this Bicep file:
- Microsoft.Storage/storageAccounts: create an Azure Storage account, which is required by Functions.
- Microsoft.Web/serverfarms: create a serverless Consumption hosting plan for the function app.
- Microsoft.Web/sites: create a Function App.
- Microsoft.Insights/components: create an Application Insights instance for monitoring.
Deploy the Bicep file using Azure CLI.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Bicep file to assign the Reader privilege to the Managed Identity of our Function App
The following Azure resource is created by this Bicep file:
- Microsoft.Authorization/roleAssignments: create a Role Assignment to let the Function App perform its audit.
Deploy the Bicep file using Azure CLI.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use Azure CLI to validate the deployment.
Perform a manual git deployment to the Azure Function App
Deploy the PowerShell code to the Function App using Azure CLI.
View the audit result Azure Application Insights
You will then be able to monitor the Function App logs being inserted every 30 minutes by navigating to you Function App > Logs as illustrated in the following screenshot.
The query:
Clean up resources
Conclusion
We saw in part 1 how to send a custom event telemetry to an Azure Application Insights instance through PowerShell, we did see in this article how to automate our audit, what about building an Azure Workbook in part 3?
Note: the complete source code we saw in this article is available here https://github.com/JamesDLD/bicep-function-app-virtual-network-monitoring
See You in the Cloud
Jamesdld
Published on:
Learn moreRelated posts
Fabric Mirroring for Azure Cosmos DB: Public Preview Refresh Now Live with New Features
We’re thrilled to announce the latest refresh of Fabric Mirroring for Azure Cosmos DB, now available with several powerful new features that e...
Power Platform – Use Azure Key Vault secrets with environment variables
We are announcing the ability to use Azure Key Vault secrets with environment variables in Power Platform. This feature will reach general ava...
Validating Azure Key Vault Access Securely in Fabric Notebooks
Working with sensitive data in Microsoft Fabric requires careful handling of secrets, especially when collaborating externally. In a recent cu...
Azure Developer CLI (azd) – May 2025
This post announces the May release of the Azure Developer CLI (`azd`). The post Azure Developer CLI (azd) – May 2025 appeared first on ...
Azure Cosmos DB with DiskANN Part 4: Stable Vector Search Recall with Streaming Data
Vector Search with Azure Cosmos DB In Part 1 and Part 2 of this series, we explored vector search with Azure Cosmos DB and best practices for...