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
This Month in Azure Static Web Apps | 09/2024
We are back with another edition of the Azure Static Web Apps Community! :party_popper: September was yet another month ...
GitHub Copilot for Azure: 6 Must-Try Features
As developers, we are constantly seeking tools that streamline our workflows and boost productivity. … Enter GitHub Copilot for Azure, now in ...
Responsible AI Mitigation Layers
Generative AI is increasingly being used in various kinds of systems to augment humans and infuse intelligent behavior into existing and new a...
Streamline Your Azure Workflow: Introducing GitHub Copilot for Azure in VS Code
I'm excited to announce the public preview of GitHub Copilot for Azure - a new addition to your toolkit that seamlessly integrates with G...
Build Intelligent Apps Code-First with Prompty and Azure AI
Building Generative AI applications can feel daunting for traditional app developers. What does the end-to-end applicati...
Certificación AI-900 (Fundamentos de IA) con Chicas en IA
La inteligencia artificial ha llegado para quedarse, ¡y más aún con la revolucionaria IA generativa! Para ayudar a los profesionales a especia...
Get certified with Learn Live GitHub series!
GitHub Universe is coming, and Microsoft and GitHub are partnering to offer a new special Learn Live series in Brazilian Portuguese, English a...
Certifícate con Learn Live GitHub en Español
Microsoft y GitHub se han unido para ofrecer una nueva serie especial de Learn Live en inglés y español: GitHub 2024. Del 10 al 24 de Octubre,...
Evaluating generative AI: Best practices for developers
As a developer working with generative AI, you've likely marveled at the impressive outputs your models can produce. But how do you ensure the...
Introducing Azure Product Retirement Livestreams
The Azure Retirements team, in collaboration with key partner groups, is excited t...