<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Villa Plus Engineering - Medium]]></title>
        <description><![CDATA[Dive into our collection of articles to explore the fascinating work we’re doing and the knowledge we are eager to spread. - Medium]]></description>
        <link>https://medium.com/villa-plus-engineering?source=rss----bc02d31bd1e4---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Villa Plus Engineering - Medium</title>
            <link>https://medium.com/villa-plus-engineering?source=rss----bc02d31bd1e4---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:41:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/villa-plus-engineering" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cutting Application Insights Costs with OpenTelemetry Sampling and Span Filtering]]></title>
            <link>https://medium.com/villa-plus-engineering/cutting-application-insights-costs-with-opentelemetry-sampling-and-span-filtering-91dd29751d1a?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/91dd29751d1a</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <category><![CDATA[application-insights]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Yuliia Merenko]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 04:54:12 GMT</pubDate>
            <atom:updated>2026-10-22T04:54:11.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Daily ingestion in the workspace, before and after the changes" src="https://cdn-images-1.medium.com/max/1024/1*87Ykg7PPoicQZrBX-Q7b-w.png" /></figure><p>After we moved several .NET services from the classic Application Insights SDK to OpenTelemetry, our Application Insights ingestion went up sharply. Nothing was wrong with the migration itself. What had changed was how much telemetry we kept.</p><p>Two fairly small changes, explicit sampling and targeted dependency filtering, accounted for most of the reduction. Together with an updated metrics transformation rule, they brought our workspace ingestion down from 2.16 GB to 0.58 GB a day, a 73% reduction, while keeping the telemetry we rely on to investigate failures.</p><p>This is a follow-up to <a href="https://medium.com/villa-plus-engineering/migrating-azure-functions-to-opentelemetry-loging-d7b1eb3d5d94">this post on our OpenTelemetry migration</a>.</p><h3>What changed after the migration</h3><p>The migration added no new business functionality, but it changed what telemetry we retained in three important ways.</p><h4>Sampling behaviour changed</h4><p>The classic Application Insights SDK had adaptive sampling enabled by default in our setup. We had never configured it, so we hadn’t paid it much attention. Before the migration, some of our busiest APIs kept only 15–35% of their telemetry.</p><p>After the migration, with OpenTelemetry .NET 1.19.1 and the Azure Monitor OpenTelemetry distro 1.6.0, our setup used rate-limited sampling. At our traffic level, almost everything was retained because requests generally stayed below the effective sampling limit. As each API moved over, its stored volume went up accordingly: by around 65% for one API and around 80% for another. The migration was intended to preserve the classic SDK’s behaviour, but the classic SDK had been sampling all along. In practice, our effective retention rate went from 15–35% to almost 100%.</p><h4>Token operations turned into dependency telemetry</h4><p>With Azure SDK tracing enabled, ManagedIdentityCredential.GetToken operations started appearing as dependencies. Almost all of them finished in under a millisecond, which was consistent with token-cache lookups rather than network calls. One API produced about two per request, and across the workspace they made up about a quarter of all dependency records. In the current Azure Monitor distro, Azure SDK tracing is an opt-in experimental feature, so it&#39;s worth checking whether yours has it switched on.</p><h4>Fast SQL queries added up</h4><p>More than 95% of our SQL dependencies were fast and successful, most well under 20 ms, and each one was stored as its own record. A slow or failed query is worth having in a trace. Hundreds of thousands of fast, successful queries a day mostly just add to the bill.</p><h3>Finding the noise</h3><p>Before changing anything, we wanted to know where the volume was coming from. Three Log Analytics queries covered most of it.</p><h4>Which tables drive ingestion?</h4><pre>Usage<br>| where TimeGenerated &gt; ago(7d) and IsBillable<br>| summarize GB = sum(Quantity) / 1000 by DataType<br>| order by GB desc</pre><p>For us, dependencies were about two thirds of total ingestion, so that’s where we started.</p><h4>Did the effective retention rate change?</h4><p>When a record is sampled, its ItemCount says how many original items it stands for. Comparing the number of stored records with the sum of ItemCount gives the share that was kept:</p><pre>union AppRequests, AppDependencies<br>| where TimeGenerated &gt; ago(90d)<br>| summarize Stored = count(), Total = sum(ItemCount)<br>          by Week = startofweek(TimeGenerated), AppRoleName<br>| extend KeptPct = round(100.0 * Stored / Total, 1)</pre><p>This showed some APIs going from 15–35% kept to effectively 100% in the week each one was migrated.</p><h4>How much of the dependency data is noise?</h4><pre>AppDependencies<br>| where TimeGenerated &gt; ago(7d)<br>| summarize Total   = count(),<br>            Token   = countif(Name has &quot;GetToken&quot;),<br>            FastSql = countif(DependencyType == &quot;SQL&quot; and Success and DurationMs &lt; 20)<br>          by AppRoleName</pre><p>Most of our dependency volume turned out to be near-instant token lookups and fast, successful SQL queries.</p><p>One thing that caught us out: in workspace-based Application Insights, the Type column holds the table name. The kind of dependency (SQL, HTTP and so on) is in DependencyType.</p><h3>Fix 1: configure sampling explicitly</h3><p>We brought sampling back, but not everywhere. Our core API stays at 100%, so every request to that API is retained, and three supporting APIs are sampled at 10%. With the Azure Monitor OpenTelemetry distro, it’s a small change:</p><pre>services.AddOpenTelemetry()<br>    .UseAzureMonitor(options =&gt;<br>    {<br>        options.SamplingRatio = 0.1f;<br>        options.TracesPerSecond = null;<br>    });</pre><p>The second line matters. Azure Monitor OpenTelemetry uses rate-limited sampling by default, with a default limit of up to 5 traces per second. When both settings are configured, TracesPerSecond takes precedence over SamplingRatio. To use ratio-based sampling, set the ratio and clear TracesPerSecond. Where we want everything kept, we say so explicitly too:</p><pre>options.SamplingRatio = 1.0f;<br>options.TracesPerSecond = null;</pre><p>That way, our sampling behaviour stays explicit rather than depending on package defaults.</p><h3>Fix 2: filter spans we don’t need</h3><p>Sampling reduces telemetry broadly, without distinguishing between useful and low-value span types. For token lookups and fast SQL queries, we wanted something more selective: keep anything that failed or was slow, and drop the fast, successful calls nobody looks at during an investigation. A small OpenTelemetry processor was enough:</p><pre>public class NoiseFilterProcessor(bool filterFastSql) : BaseProcessor&lt;Activity&gt;<br>{<br>    private static readonly TimeSpan TokenMax = TimeSpan.FromMilliseconds(50);<br>    private static readonly TimeSpan SqlMax   = TimeSpan.FromMilliseconds(20);<br>    public override void OnEnd(Activity a)<br>    {<br>        if (a.Status == ActivityStatusCode.Error) return;<br>        if (a.Duration &lt; TokenMax &amp;&amp;<br>            a.DisplayName.EndsWith(&quot;GetToken&quot;, StringComparison.Ordinal))<br>        {<br>            a.ActivityTraceFlags &amp;= ~ActivityTraceFlags.Recorded;<br>            return;<br>        }<br>        if (filterFastSql &amp;&amp; a.Kind == ActivityKind.Client &amp;&amp; a.Duration &lt; SqlMax &amp;&amp;<br>            (a.GetTagItem(&quot;db.system&quot;) ?? a.GetTagItem(&quot;db.system.name&quot;)) is not null)<br>        {<br>            a.ActivityTraceFlags &amp;= ~ActivityTraceFlags.Recorded;<br>        }<br>    }<br>}</pre><p>Unlike trace sampling, the processor makes a targeted decision about each completed span. A successful SQL query under 20 ms is dropped, while a failed or slow one is kept. Token operations follow the same principle, using their own 50 ms threshold.</p><h4>Processor ordering matters</h4><p>The processor has to run before the exporter. Otherwise the span may already be queued for export by the time the Recorded flag is cleared. We register it before Azure Monitor:</p><pre>services.ConfigureOpenTelemetryTracerProvider((sp, builder) =&gt;<br>    builder.AddProcessor(new NoiseFilterProcessor(filterFastSql: true)));<br>services.AddOpenTelemetry()<br>    .UseAzureMonitor(/* ... */);</pre><p>We made SQL filtering a switch because it’s a trade-off. If a request fails after several fast, successful queries, those queries won’t be in the trace. That was fine for these services, but it’s worth deciding per application rather than turning it on everywhere.</p><h3>Results</h3><p>Once all the changes were live, total workspace ingestion was 73% lower.</p><figure><img alt="Application Insights workspace ingestion before and after the changes" src="https://cdn-images-1.medium.com/max/1024/1*YAzY_aOfxwLyK66C9K9qNw.png" /></figure><p>Most of the reduction came from dependencies. Metrics fell separately after we updated the workspace transformation rule from <a href="https://medium.com/villa-plus-engineering/migrating-azure-functions-to-opentelemetry-loging-d7b1eb3d5d94">the previous post</a> to match the newer .NET runtime metric names. Ingestion is billed by data volume, so our ingestion cost fell by roughly the same proportion. Any additional retention charges would also decrease over time as the older, higher-volume telemetry ages out.</p><p>Response times didn’t change, and we keep the telemetry we need when something fails or slows down.</p><h3>What I would check after an OpenTelemetry migration</h3><p>The main thing we learned is that an OpenTelemetry migration changes more than the library. Sampling, which dependencies get instrumented, how logs are filtered and how much data reaches Application Insights can all shift without anyone touching application code.</p><p>If you’ve migrated recently, start with the Usage table to see which telemetry types drive your bill, then compare the share of telemetry kept before and after the migration using ItemCount. Count GetToken operations and fast, successful SQL dependencies; if they make up a large share, a filter like ours is cheap to add. And set sampling explicitly, including TracesPerSecond, rather than relying on defaults.</p><p>For us, those checks led to a 73% cut in Application Insights ingestion, with a few lines of configuration and one small processor.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91dd29751d1a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/cutting-application-insights-costs-with-opentelemetry-sampling-and-span-filtering-91dd29751d1a">Cutting Application Insights Costs with OpenTelemetry Sampling and Span Filtering</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating .NET]]></title>
            <link>https://medium.com/villa-plus-engineering/automating-net-deb9413776a8?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/deb9413776a8</guid>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Som Das]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 11:21:33 GMT</pubDate>
            <atom:updated>2026-10-16T11:21:32.622Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automating .NET Runtime Upgrades in Azure App Service: From Manual Configuration to Reusable Deployment Pipelines</h3><p><em>How we approached .NET runtime migration at Villa Plus using Azure DevOps, PowerShell scripts and deployment slots — and how the solution can evolve into a reusable engineering practice.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ahZpnmA-8EApk9oqZsT3A.png" /><figcaption>.NET Upgrade Deployment Automation</figcaption></figure><h3>1. Introduction</h3><p>Upgrading a .NET application to a newer framework is often considered a development activity. We update the target framework, resolve package dependencies, address breaking changes, build the application and deploy it.</p><p>But what happens when the application hosting environment is still configured for the previous .NET runtime?</p><p>This is a challenge we encountered while managing .NET applications hosted on Azure App Service at Villa Plus.</p><p>Our applications use Azure DevOps release pipelines and Azure App Service deployment slots to manage deployments across environments.</p><p>During major .NET migrations, we identified an important prerequisite: <strong>the Staging slot must be configured with a runtime compatible with the new application before the upgraded application can start successfully.</strong></p><p>Traditionally, this involved updating the runtime manually in Azure before executing the release.</p><p>While relatively straightforward for a single application, repeating this process across multiple services introduced operational overhead and the possibility of human error.</p><p>We decided to automate it.</p><p>This article explains our approach, the ARM template implementation, the deployment considerations we discovered, and how the solution can evolve into a shared deployment capability.</p><h3>2. Understanding the Problem</h3><p>Consider a typical deployment scenario.</p><p>An API is currently running on .NET 9, and the development team has completed its migration to .NET 10.</p><p>The application binaries are ready, but the Azure App Service Staging slot is still configured to use .NET 9.</p><p>Our existing release workflow looks broadly like this:</p><pre>Build Application (.NET 10)<br>          |<br>          v<br>Publish Build Artifacts<br>          |<br>          v<br>Start App Service — Staging<br>          |<br>          v<br>Deploy Application Binaries<br>          |<br>          v<br>Validate and Swap Staging to Production Slot</pre><p>The problem is that the hosting environment and application are not compatible now as the new binaries are in .NET 10 and the hosting environment still configured as .NET 9.</p><p>Depending on the deployment method, the package might be uploaded successfully, but the application may fail to start because the required runtime is unavailable.</p><p>This distinction matters: a successful package deployment does not automatically mean a successful application deployment.</p><h3>Why not update the runtime manually?</h3><p>Manual configuration introduces several challenges:</p><ul><li><strong>Human dependency:</strong> Engineers must remember to update the runtime before a major migration.</li><li><strong>Configuration drift:</strong> Different environments may have different runtime settings.</li><li><strong>Deployment failures:</strong> A mismatch may only become apparent when the application starts.</li><li><strong>Limited scalability:</strong> Coordinating changes becomes harder as the number of services grows.</li><li><strong>Reduced traceability:</strong> Manual configuration changes are harder to associate with a particular application release.</li><li><strong>Accidental Damage:</strong> If involved engineer changes the configuration of wrong slot accidentally the whole service operation will be jeopardised.</li></ul><p>Our goal was to make runtime configuration a controlled part of the deployment lifecycle.</p><h3>3. Our Solution: A Reusable, Runtime-Aware Deployment Automation</h3><p>To eliminate manual runtime configuration and avoid duplicating deployment logic across multiple services, we designed a reusable PowerShell-based automation that integrates with our existing Azure DevOps release pipelines.</p><p>The idea is straightforward:</p><p><strong>Before deploying a .NET application, ensure that the target Azure App Service deployment slot is configured with the required runtime version.</strong></p><p>Rather than blindly updating the runtime during every deployment, the automation checks the current configuration and only makes changes when necessary.</p><h3>How It Works</h3><p>The automation follows five simple steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QnwsfH7I-kHKt2mLcT0DEw.png" /></figure><p>This makes the solution <strong>idempotent</strong>: running the same automation repeatedly with the same target configuration does not introduce unnecessary changes.</p><h3>The Generic PowerShell Script</h3><p>We implemented the logic in a PowerShell script named Ensure-DotNetRuntime.ps1.</p><p>The script accepts four parameters, allowing it to work across different applications without modifying the underlying implementation.</p><p>ParameterDescriptionAppServiceNameName of the target Azure App ServiceResourceGroupResource group containing the App ServiceSlotNameDeployment slot, defaulting to stagingTargetRuntimeRequired runtime, e.g. DOTNETCORE|10.0</p><p>Here is the implementation:</p><pre>param(<br>    [Parameter(Mandatory = $true)]<br>    [string]$ResourceGroup,<br>    [string]$SlotName = &quot;staging&quot;,<br>    [Parameter(Mandatory = $true)]<br>    [string]$TargetRuntime<br>)<br>$ErrorActionPreference = &quot;Stop&quot;<br>Write-Host &quot;Checking runtime for $AppServiceName/$SlotName&quot;<br># Retrieve current runtime<br>$currentRuntime = az webapp config show `<br>    --name $AppServiceName `<br>    --resource-group $ResourceGroup `<br>    --slot $SlotName `<br>    --query linuxFxVersion `<br>    --output tsv<br>if ($LASTEXITCODE -ne 0) {<br>    throw &quot;Failed to retrieve App Service runtime.&quot;<br>}<br>Write-Host &quot;Current runtime: $currentRuntime&quot;<br>Write-Host &quot;Target runtime: $TargetRuntime&quot;<br># Skip when the runtime already matches<br>if ($currentRuntime -eq $TargetRuntime) {<br>    Write-Host &quot;Runtime already matches. No update needed.&quot;<br>    return<br>}<br># Update runtime<br>Write-Host &quot;Updating runtime to $TargetRuntime&quot;<br>az webapp config set `<br>    --name $AppServiceName `<br>    --resource-group $ResourceGroup `<br>    --slot $SlotName `<br>    --linux-fx-version $TargetRuntime `<br>    --output none<br>if ($LASTEXITCODE -ne 0) {<br>    throw &quot;Runtime update failed.&quot;<br>}<br># Verify the updated runtime<br>$updatedRuntime = az webapp config show `<br>    --name $AppServiceName `<br>    --resource-group $ResourceGroup `<br>    --slot $SlotName `<br>    --query linuxFxVersion `<br>    --output tsv<br>if ($LASTEXITCODE -ne 0 -or $updatedRuntime -ne $TargetRuntime) {<br>    throw &quot;Runtime verification failed.&quot;<br>}<br>Write-Host &quot;Runtime updated successfully to $TargetRuntime&quot;</pre><h3>Why This Approach?</h3><p>This solution provides several advantages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohwg9Gl-o2_hzJhg22emlg.png" /></figure><p>The implementation targets Linux-based Azure App Services using the built-in .NET runtime. The script assumes the target runtime is supported; runtime availability and slot-state validation are additional safeguards to introduce before broad production adoption.</p><h3>A Note on Deployment Ordering</h3><p>Updating the runtime can restart the App Service, and an application compiled for an older .NET version may not start successfully under a newer runtime configuration.</p><p>For this reason, the runtime check is performed before deploying the new application binaries, with the expectation that the Staging environment may temporarily be unavailable during a major framework migration.</p><p>The release must only proceed to Production after the new application has been deployed and successfully validated through health checks or smoke tests.</p><p>This is particularly important when using Azure App Service deployment slots, where the validated application and its compatible runtime configuration can be promoted together through a slot swap.</p><h3>4. Centralising and Versioning the Automation</h3><p>One of our key objectives was to make this automation reusable across multiple engineering teams without duplicating the same script in different repositories.</p><p>At Villa Plus, our applications are organised into separate Azure DevOps projects, each with its own repositories and deployment pipelines.</p><p>Rather than maintaining individual copies of the runtime validation script, we created a dedicated Azure DevOps project to host shared engineering automation.</p><p><strong>Our repository structure:</strong></p><pre>DevOps-Support (Azure DevOps Project)<br>│<br>└── DevOps.Automation (Git Repository)<br>    │<br>    ├── scripts/<br>    │   └── dotnet/<br>    │       └── Ensure-DotNetRuntime.ps1<br>    │<br>    └── README.md</pre><p>This repository acts as a central location for reusable DevOps utilities that can be consumed by different teams.</p><h3>Versioning with Git Tags</h3><p>Centralising automation introduces an important consideration: how do we prevent changes to a shared script from unexpectedly affecting existing deployment pipelines?</p><p>Our solution was to use Git tags.</p><p>After committing the initial implementation, we created a version tag:</p><pre>git tag v1.0.0<br>git push origin v1.0.0</pre><p>This allows each consuming pipeline to reference a specific version of the automation rather than always retrieving the latest changes from the main branch.</p><p>For example, a pipeline using v1.0.0 continues to retrieve the same script even when improvements are subsequently committed to the repository.</p><p>When changes are required, we can introduce new versions such as v1.0.1 or v1.1.0depending upon the nature of changes.</p><p>This provides predictable deployments, traceability, controlled adoption and a straightforward way to revert to an earlier script version.</p><h3>5. Integrating with Existing Azure DevOps Release Pipelines</h3><p>The next step was to integrate the shared automation into existing deployment pipelines without redesigning their established release processes.</p><p>Our applications use Azure App Service deployment slots, with releases typically following this sequence:</p><pre>Start Staging Slot<br>        |<br>        v<br>Deploy Application<br>        |<br>        v<br>Run Smoke Tests<br>        |<br>        v<br>Swap Staging → Production<br>        |<br>        v<br>Stop Staging Slot</pre><p>To introduce runtime validation, we only need to add two tasks before the existing deployment sequence.</p><h3>Updated Deployment Workflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xxGwc3L22VX_dpIKXAavw.png" /></figure><p>This allows the runtime configuration to be validated before the new application binaries are deployed.</p><p>In our environment, the Staging slot is normally stopped after a successful release. The runtime update is therefore positioned before the existing Start Staging task.</p><p>However, changing App Service configuration can restart the application, so deployment logic must not assume that a previously stopped slot will remain stopped. Slot state and compatibility should be verified during rollout.</p><h3>Task 1: Retrieve the Shared Script</h3><p>For Azure DevOps Classic Release pipelines, the shared repository must first be made available on the release agent.</p><p>We can achieve this using a PowerShell task that retrieves a specific Git tag.</p><pre>$repoUrl = &quot;https://dev.azure.com/YOUR_ORG/DevOps-Support/_git/DevOps.Automation&quot;<br><br>$destination = &quot;$(Agent.TempDirectory)/DevOps.Automation&quot;<br># Retrieve a specific version of the shared automation<br>git -c http.extraheader=&quot;AUTHORIZATION: bearer $env:SYSTEM_ACCESSTOKEN&quot; `<br>    clone --depth 1 --branch v1.0.0 `<br>    $repoUrl $destination<br>if ($LASTEXITCODE -ne 0) {<br>    throw &quot;Failed to retrieve shared automation.&quot;<br>}</pre><p>The repository URL is illustrative and should be replaced with the organisation’s actual Azure DevOps URL.</p><p>The pipeline uses an authorised job access token rather than storing credentials in the script.</p><p>For this to work, the Classic Release agent job must expose its OAuth token to scripts, and its build service identity must have read access to the shared repository. Organisation-level job authorisation and repository protection settings may also require configuration.</p><h3>Task 2: Ensure the Required .NET Runtime</h3><p>Once the script has been retrieved, the next task executes it using Azure CLI with PowerShell Core.</p><pre>&amp; &quot;$(Agent.TempDirectory)/DevOps.Automation/scripts/dotnet/Ensure-DotNetRuntime.ps1&quot; `<br>    -AppServiceName &quot;$(AppServiceName)&quot; `<br>    -ResourceGroup &quot;$(ResourceGroupName)&quot; `<br>    -SlotName &quot;$(SlotName)&quot; `<br>    -TargetRuntime &quot;$(TargetDotNetRuntime)&quot;</pre><p>The Azure CLI task authenticates to Azure using the appropriate service connection, with permissions to read and update the target App Service configuration.</p><h3>Configuring Pipeline Variables</h3><p>Each application supplies its own configuration through Azure DevOps pipeline variables.</p><p>For example:</p><p>VariableExampleAppServiceNametest-ecommerce-api-appResourceGroupNametest-ecommerceSlotNamestagingTargetDotNetRuntimeDOTNETCORE|10.0</p><p>The runtime variable should match the runtime required by the application artifact being deployed.</p><p>This means the same shared script can be consumed by different applications, with no application-specific changes to the implementation.</p><h3>What Happens During Deployment?</h3><p>Consider two scenarios.</p><p><strong>Scenario 1: Normal application deployment</strong></p><p>The Staging slot is already configured for .NET 10, and the incoming application also targets .NET 10.</p><p>The script detects that the runtime already matches and skips the update.</p><p>The deployment continues normally.</p><p><strong>Scenario 2: Framework upgrade</strong></p><p>The Staging slot is configured for .NET 9, but the incoming application targets .NET 10.</p><p>The script detects the mismatch, updates the runtime configuration and verifies the result.</p><p>The pipeline then deploys the new binaries and executes the existing smoke tests.</p><p>Only after successful validation does the release proceed to the Production slot swap.</p><p>If the runtime configuration update fails, the release stops before deploying the new application.</p><h3>Important Deployment Considerations</h3><p>The runtime update is only one part of a safe framework migration.</p><p>Before adopting this approach broadly, teams should ensure that:</p><ul><li>The target runtime is supported by the App Service platform and hosting environment.</li><li>The deployment slot uses Linux App Service with the built-in .NET runtime.</li><li>Configuration updates do not unintentionally affect other App Service settings.</li><li>The Staging application passes health checks and smoke tests before the swap.</li><li>Rollback procedures account for runtime compatibility, particularly when the previous Production application returns to Staging after a swap.</li></ul><p>These checks help ensure that the automation improves deployment reliability rather than simply replacing a manual configuration step.</p><h3>Final Thoughts</h3><p>The real value of DevOps automation is not always in building sophisticated deployment platforms or introducing additional infrastructure.</p><p>Sometimes, a small, well-designed script can eliminate a recurring operational problem across multiple teams.</p><p>By combining Azure CLI, PowerShell, Git versioning and Azure DevOps, we have established a lightweight approach to runtime-aware deployments that can evolve alongside our applications.</p><blockquote><strong>The goal is simple: make the correct deployment configuration part of the process, rather than something engineers have to remember.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb9413776a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/automating-net-deb9413776a8">Automating .NET</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Cloning Azure DevOps Repos One by One (Do This Instead)]]></title>
            <link>https://medium.com/villa-plus-engineering/stop-cloning-azure-devops-repos-one-by-one-do-this-instead-c2ce00492504?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/c2ce00492504</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Sumeet Patil]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 04:57:12 GMT</pubDate>
            <atom:updated>2026-10-14T04:57:11.233Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uM123LVg-MDcBKA-qUB5UQ.png" /></figure><p>If you’ve ever had to manually clone multiple repositories for a project from Azure DevOps (VSTS), you know exactly how tedious it can be.</p><blockquote>Copy link. Open terminal. git clone. Paste. Repeat 20 times.</blockquote><p>Whether you’re onboarding a new developer, doing mass refactoring, or running codebase metrics across repositories, doing this manually is a massive waste of time. To save everyone some sanity, here is a quick guide and a PowerShell script to automate the process and clone all repositories in a project simultaneously.</p><p>Let’s automate the boring stuff.</p><p><strong>Step 1: One-Time Setup</strong></p><p>First, you need the Azure CLI and the DevOps extension. Open PowerShell as an Administrator and run these two quick commands:</p><pre>winget install --exact --id Microsoft.AzureCLI<br><br>az extension add --name azure-devops</pre><p><strong>Step 2: Grab a Token</strong></p><p>Go to your Azure DevOps settings and generate a Personal Access Token (PAT). Only give it <strong>Read </strong>permissions for code, and set it to expire quickly (e.g., 1 day) for security.</p><p><strong>Step 3: The Magic Script</strong></p><p>Open PowerShell in the folder where you want all these repos to live. Update your Project and Organization names in the script below, paste your PAT, and hit run.</p><pre># 1. Configuration<br>$Organization = &quot;YourOrgName&quot;<br>$Project = &quot;YourProjectName&quot;<br>$env:AZURE_DEVOPS_EXT_PAT = &quot;PASTE_YOUR_PAT_HERE&quot;<br><br># 2. Set defaults so we don&#39;t have to pass them every time<br>az devops configure --defaults organization=https://dev.azure.com/$Organization project=$Project<br><br># 3. Fetch all repositories and clone them<br>Write-Host &quot;Fetching repository list from $Project...&quot; -ForegroundColor Cyan<br>$repos = az repos list --query &quot;[].{name:name, cloneUrl:webUrl}&quot; --output json | ConvertFrom-Json<br><br>Write-Host &quot;Found $($repos.Count) repositories. Starting clones...&quot; -ForegroundColor Green<br><br>foreach ($repo in $repos) {<br>    Write-Host &quot;Cloning $($repo.name)...&quot; -ForegroundColor Yellow<br>    git clone $repo.cloneUrl<br>}<br><br># 4. Clean up token from memory<br>Remove-Item env:\AZURE_DEVOPS_EXT_PAT<br>Write-Host &quot;Done! Session token cleared.&quot; -ForegroundColor Green</pre><p><strong>Why This Works</strong></p><p>The script queries Azure DevOps for every repo in your specific project, extracts the clone URLs, and loops through them with standard git clone commands. Best of all, it cleans up your PAT from the environment variables right after it finishes so you don’t leave credentials hanging around in memory.</p><p>If this saved you some time, do share it with your team so they can stop copying and pasting, too.</p><p><em>Happy coding!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2ce00492504" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/stop-cloning-azure-devops-repos-one-by-one-do-this-instead-c2ce00492504">Stop Cloning Azure DevOps Repos One by One (Do This Instead)</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tracking Email Delivery Status with Webhooks: From “Sent” to “Actually Delivered”]]></title>
            <link>https://medium.com/villa-plus-engineering/tracking-email-delivery-status-with-webhooks-from-sent-to-actually-delivered-4de8dc0a1003?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/4de8dc0a1003</guid>
            <category><![CDATA[email]]></category>
            <category><![CDATA[api-design]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[webhooks]]></category>
            <dc:creator><![CDATA[Sajeesh Kumar A]]></dc:creator>
            <pubDate>Tue, 25 Aug 2026 08:41:16 GMT</pubDate>
            <atom:updated>2026-08-25T11:21:06.988Z</atom:updated>
            <content:encoded><![CDATA[<p>This article covers how we have added delivery status tracking using webhooks. Picking webhooks over polling was the easy part. The harder part was working out how an event that only carries the provider’s own IDs finds its way back to the right record in our system.</p><p>Our provider is SparkPost (now part of Bird after the acquisition), so the field names below are theirs. The pattern itself isn’t. Every major provider lets you attach your own data to a message and hands it back on the event: SendGrid calls it custom_args, Mailgun calls it user variables, Postmark calls it metadata, Amazon SES calls them message tags. If your provider does this, everything here applies with a rename.</p><h3>1. Push, not pull</h3><p>SparkPost can tell you about delivery in two ways. You can poll it, calling the Events API on a schedule and checking what happened since the last time you looked. Or it can push to you, sending an event to your endpoint the moment something happens.</p><p>Polling means choosing an interval, and that choice is a trade. Poll often and you spend most of your calls learning nothing has changed. Poll rarely and a bounce sits unnoticed for however long the gap is. It also means running a scheduler and tracking a cursor, so you know where you left off and don’t re-read the same events on every run. Pushing has no interval to tune and no cursor to keep. We chose push.</p><h3>2. The problem push creates</h3><p>Here is a SparkPost delivery event, cut down to the parts that matter:</p><pre>{<br>   &quot;msys&quot;: {<br>     &quot;message_event&quot;: {<br>     &quot;type&quot;: &quot;delivery&quot;,<br>     &quot;message_id&quot;: &quot;000443ee5bf013ef5a44&quot;,<br>     &quot;transmission_id&quot;: &quot;65832150921904138&quot;,<br>     &quot;rcpt_to&quot;: &quot;guest@example.com&quot;,<br>     &quot;rcpt_meta&quot;: {}<br>     }<br>   }<br> }</pre><p>Every ID in there belongs to SparkPost. Our system is organized around our own records. The event knows exactly what happened to SparkPost’s message, but it has no way of knowing which email sent by us it belongs to.</p><p>So the question was: when an event turns up an hour after the send, how does it find its way back to the right record?</p><h3>3. Two options</h3><p><strong>Option A, a mapping table.</strong> On send, write down SparkPost’s ID next to a pointer to our record. When an event arrives, look it up.</p><p>It works, but it is a whole new piece of infrastructure whose only job is answering <em>who does this email belong to?</em></p><p><strong>Option B, let SparkPost carry the answer.</strong> SparkPost lets you attach your own metadata to a message when you send it. The metadata means nothing to SparkPost, and it comes back untouched on every event about that message.</p><p>We picked B, and then took it one step further. Instead of attaching an ID that we would still have to resolve on our side, we attached a <strong>REST status update link that is unique to that email</strong>. The webhook handler doesn’t look anything up. It reads the link straight out of the event and calls it with the status. We didn’t make the lookup faster. We deleted it.</p><p><strong>Note:</strong> we send one recipient per transmission, so we set the metadata at transmission level and read it back from rcpt_meta. That keeps the whole thing simple, because there is no per-recipient status to untangle. If you batch several recipients into a single transmission this falls apart, since transmission-level metadata stamps the same value onto every message and every event will point at the same record. In that case the correlation value has to move to recipients[].metadata instead.</p><h3>4. Sending the link</h3><p>POST <a href="https://api.sparkpost.com/api/v1/transmissions">https://api.sparkpost.com/api/v1/transmissions</a></p><pre>POST https://api.sparkpost.com/api/v1/transmissions<br><br>{<br>  &quot;campaign_id&quot;: &quot;campaignId&quot;,<br>  &quot;metadata&quot;: {<br>  &quot;status_update_url&quot;: &quot;https://&lt;host&gt;/api/notifications/8f1c2d64-…/status&quot;<br>  },<br>  &quot;recipients&quot;: [<br>    { &quot;address&quot;: { &quot;email&quot;: &quot;guest@example.com&quot; } }<br>  ],<br>  &quot;content&quot;: { &quot;template_id&quot;: &quot;campaignId&quot; }<br>}</pre><p>Correlation data goes in metadata.</p><h3>5. Handling the event</h3><p>The link we sent comes back in rcpt_meta, exactly as we wrote it:</p><pre>&quot;rcpt_meta&quot;: {<br>  &quot;status_update_url&quot;: &quot;https://&lt;host&gt;/notifications/8f1c2d64-…/status&quot;<br>}</pre><p>That single field is the whole correlation step. There is no ID to translate and no table to consult. The handler reads the URL, works out whether the message made it, and calls the URL with the status. When it didn’t make it, we pass the reason along too, taken from the reason field on the event, so support can see <em>why</em> an email failed instead of just that it did. A hard bounce from a dead mailbox and a rejection for a bad sending domain look identical without it.</p><p>We only care about the final outcomes. A delivery event means it arrived. Everything in this set means it didn’t:</p><pre>private static readonly HashSet&lt;string&gt; NotDeliveredEventTypes = new(StringComparer.OrdinalIgnoreCase)<br> {<br>   &quot;bounce&quot;,<br>   &quot;out_of_band&quot;,<br>   &quot;spam_complaint&quot;,<br>   &quot;policy_rejection&quot;,<br>   &quot;delay&quot;<br> };</pre><p>Anything outside those two buckets is ignored.</p><p><strong>Note:</strong> delay is the odd one out in that list, because it isn’t final. SparkPost will keep retrying a delayed message and may well deliver it in the end, so a delayed-then-delivered email shows as not delivered first and flips to delivered later.</p><h3>6. The 10-second limit</h3><p>SparkPost gives your endpoint 10 seconds to answer. Miss it and the whole batch is treated as failed and queued for retry.</p><p>That leaves two options: finish everything inside 10 seconds, or accept the batch immediately and do the real work somewhere else. Doing the work inline is tempting because it is less code, but it is also exactly the kind of thing that quietly creeps past the limit as volume grows. Parsing, validating, calling status URLs and writing to the database all add up, and each of those steps depends on something that can have a slow day.</p><p>We used an <strong>Azure Durable Function</strong>. The HTTP endpoint does almost nothing: it hands the batch to a durable orchestration and returns 200 straight away. The orchestration then works through the events at its own pace, with retries and state handled for us. SparkPost sees a fast, dependable endpoint, and a slow downstream call can no longer cause a redelivery.</p><h3>7. Securing the endpoint</h3><p>A webhook endpoint is public by definition, and this one accepts instructions about the delivery state of customer email. Left open, anyone who finds the URL can post whatever status they like. SparkPost gives you a few ways to close that off, set when you register the webhook.</p><p><strong>Basic authentication.</strong> You supply a username and password when creating the webhook, and SparkPost sends them on every POST. Simple, widely understood, and enough for most cases as long as you are on HTTPS and treat the password like any other secret, meaning it lives in a vault and gets rotated.</p><p><strong>OAuth 2.0.</strong> Instead of a static credential, you give SparkPost the details it needs to fetch a token, and it presents that token on each request. More moving parts, but the credential on the wire is short-lived, which matters more the longer the integration lives.</p><p>Whichever you pick, register the endpoint only after it is live and returning 200. SparkPost sends a test POST when you set or change the target URL, and if that test doesn’t come back 200 the API rejects the whole request and the webhook is never created.</p><h3>Conclusion</h3><p>Choosing webhooks over polling was the easy part. The work was in the correlation, and the instinct there is to build a table that remembers which message belongs to which record. We didn’t need one. SparkPost was already tracking the message in order to send it, so we asked it to carry a link back to us and let it do the remembering.</p><p>One thing we’re adding next: a digital signature on the status update link itself. The correlation link travels through SparkPost and comes back to us inside the event, which means we’re trusting SparkPost to hand back exactly what we sent. If SparkPost were ever compromised, that trust becomes the attack surface, an attacker could inject their own value into rcpt_meta and have our handler call an arbitrary URL, since right now we call whatever link the event contains. Signing the link when we generate it, and verifying that signature before acting on it, means the handler only ever trusts a URL it can prove came from us, not merely one that arrived through a channel we normally trust</p><h3>References</h3><ul><li><a href="https://developers.sparkpost.com/api/transmissions/">Transmissions API</a></li><li><a href="https://developers.sparkpost.com/api/webhooks/">Event Webhooks API</a></li><li><a href="https://developers.sparkpost.com/api/events/">Events API</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4de8dc0a1003" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/tracking-email-delivery-status-with-webhooks-from-sent-to-actually-delivered-4de8dc0a1003">Tracking Email Delivery Status with Webhooks: From “Sent” to “Actually Delivered”</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upgrading Azure Functions to .NET 10: A Practical Flex Consumption Migration Guide]]></title>
            <link>https://medium.com/villa-plus-engineering/migrating-azure-functions-from-linux-consumption-to-flex-consumption-for-net-10-bffb77e2ca58?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/bffb77e2ca58</guid>
            <category><![CDATA[dotnet-10]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Swetha Alampally]]></dc:creator>
            <pubDate>Thu, 13 Aug 2026 05:15:55 GMT</pubDate>
            <atom:updated>2026-09-17T09:33:31.638Z</atom:updated>
            <content:encoded><![CDATA[<p>This article outlines the migration of Azure Functions from the Linux Consumption hosting plan to Flex Consumption, undertaken as a prerequisite for upgrading to .NET 10 isolated. It covers the infrastructure and pipeline changes required, the problems encountered during the migration, and the validation steps used to confirm the new Function Apps were working correctly.</p><p>.NET 10 isolated does not run on Linux Consumption (Y1) at all — the plan doesn’t support it. Flex Consumption is Microsoft’s recommended target for most Consumption workloads moving forward.</p><h3>1. Why Flex Consumption</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UiyoLHbGKWRxwKhnzGYGw.png" /></figure><p>If a function needs to reach a resource inside a private network — a database or API with no public endpoint — Linux Consumption cannot do this at all, while Flex Consumption can. Even without a VNet requirement, the memory and scaling controls make Flex the better default for new and migrated workloads.</p><p>Beyond VNet access, the other differences in the table above translate into real operational benefits. Fixed instance memory on Linux Consumption means you either overpay for headroom you don’t need, or risk out-of-memory failures during traffic spikes with no way to size up. Flex Consumption’s configurable memory (512 MB to 4,096 MB) lets you match the plan to actual usage. Scaling is similarly coarse on Linux Consumption — the whole app scales as a single unit, which makes it hard to reason about throughput when one function is busy and others are idle. Flex Consumption scales each function independently, and Always-ready instances let latency-sensitive functions skip cold starts entirely, something Linux Consumption has no equivalent for.</p><p>None of this is optional if .NET 10 is the target, since Linux Consumption doesn’t support it at all — but even without that constraint, the memory and scaling improvements alone make Flex Consumption the better choice for most workloads moving off Consumption.</p><p>Docs: <a href="https://learn.microsoft.com/azure/azure-functions/functions-versions">Azure Functions runtime versions</a> · <a href="https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/main/plugin/skills/azure-upgrade/references/services/functions/consumption-to-flex.md">Consumption to Flex migration reference</a></p><h3>2. Choosing a Migration Approach</h3><p><strong>Two-step migration (recommended)</strong> — a seamless migration for an app that must stay running. The existing Linux Consumption app is left untouched while the new Flex app is built and validated alongside it; cutover happens only once the new app is confirmed working.</p><ol><li>Create the Flex Consumption plan and a new Function App (One Function App per Flex Consumption Plan).</li><li>Deploy the existing .NET 8 build (no runtime change yet). Validate all functions and triggers.</li><li>Update the runtime to .NET 10 isolated, deploy a .NET 10 build, and validate again.</li><li>Remove the old Linux Consumption app and plan.</li></ol><p><strong>Single-step migration</strong> — create the Flex plan, deploy .NET 10 directly, validate, remove old resources. Faster, but only viable for apps that can be paused for the migration window, and harder to debug since the plan change and runtime change land together.</p><h3>3. Reviewing Current Usage</h3><p>Before sizing the new Function App, pull real numbers from Application Insights rather than guessing at instance memory, timeout, or scale settings. The following are <strong>KQL (kusto) </strong>queries, run from the Application Insights Logs blade.</p><p>Execution duration and failure count:</p><pre>requests <br>| summarize <br>    Count = count(), <br>    AvgDurationMs = avg(duration), <br>    MaxDurationMs = max(duration), <br>    FailureCount = countif(success == false) <br>by name <br>| order by MaxDurationMs desc</pre><p>Memory usage:</p><pre>performanceCounters<br>| where cloud_RoleName == &quot;&lt;FunctionAppName&gt;&quot;<br>| where name == &quot;Private Bytes&quot;<br>| summarize<br>    AvgMemoryMB = avg(value) / 1024 / 1024,<br>    MaxMemoryMB = max(value) / 1024 / 1024<br>by bin(timestamp, 1d)<br>| order by timestamp desc</pre><p>CPU usage:</p><pre>performanceCounters<br>| where name == &quot;% Processor Time&quot;<br>| summarize<br>    AvgCPU = avg(value),<br>    MaxCPU = max(value)<br>by bin(timestamp, 1h)<br>| order by timestamp desc</pre><p>Out-of-memory exceptions (any results here indicate the app is already under-provisioned):</p><pre>exceptions<br>| where type contains &quot;OutOfMemory&quot;<br>| project timestamp, type, message</pre><p>Failed executions:</p><pre>requests<br>| where success == false<br>| summarize FailureCount = count()<br>by name, resultCode<br>| order by FailureCount desc</pre><p>Cold starts:</p><pre>traces<br>| where message contains &quot;Host started&quot;<br>    or message contains &quot;cold&quot;<br>| project timestamp, message</pre><p>Note: a | where timestamp &gt; ago(...) clause can be added back to any of these to limit the time range; it&#39;s omitted above to use the full retention window by default.</p><h3>4. Infrastructure Setup (Bicep)</h3><p>Service plan:</p><pre>resource FunctionAppServicePlan &#39;Microsoft.Web/serverfarms@2024-11-01&#39; = {<br>  name: FunctionAppServicePlanName<br>  location: ResourceGroupLocation<br>  sku: {<br>    name: &#39;FC1&#39;<br>    tier: &#39;FlexConsumption&#39;<br>  }<br>  kind: &#39;functionapp&#39;<br>  properties: {<br>    reserved: true<br>  }<br>}</pre><p>On Linux Consumption, FUNCTIONS_EXTENSION_VERSION and FUNCTIONS_WORKER_RUNTIME are set as App Settings. On Flex Consumption, Azure rejects the deployment if these are set as App Settings - they move into a functionAppConfig block on the site resource instead:</p><pre>functionAppConfig: {<br>  runtime: {<br>    name: &#39;dotnet-isolated&#39;<br>    version: &#39;10.0&#39;<br>  }<br>  scaleAndConcurrency: {<br>    instanceMemoryMB: 512<br>    maximumInstanceCount: 1<br>  }<br>}</pre><h3>5. Function Timeout Defaults</h3><p>The default and maximum execution time also change between plans, controlled by functionTimeout in host.json:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*D3h85_AT0RAvufCJZBUjuA.png" /></figure><p>host.json:</p><pre>{<br>  &quot;version&quot;: &quot;2.0&quot;,<br>  &quot;functionTimeout&quot;: &quot;00:40:00&quot;<br>}</pre><p>Note: Flex Consumption has no hard maximum, but Azure still applies a 60-minute grace period during scale-in and a 10-minute grace period during platform updates — a long-running function can still be interrupted by either. Setting functionTimeout to &quot;00:00:00&quot; does not disable the timeout or override these platform-level limits.</p><p>Note: HTTP-triggered functions must respond within 230 seconds regardless of functionTimeout, due to the underlying Azure Load Balancer&#39;s idle timeout. This applies on both plans and cannot be changed via functionTimeout. Work that takes longer should return an immediate response and continue processing in the background.</p><h3>6. Deployment Storage Configuration</h3><p>Flex Consumption requires a dedicated blob container to hold the deployed code package, declared in functionAppConfig.deployment:</p><pre>functionAppConfig: {<br>  deployment: {<br>    storage: {<br>      type: &#39;blobContainer&#39;<br>      value: &#39;${StorageAccountBlobEndpoint}deployment-package&#39;<br>      authentication: {<br>        type: &#39;StorageAccountConnectionString&#39;<br>        storageAccountConnectionStringName: &#39;DEPLOYMENT_STORAGE_CONNECTION_STRING&#39;<br>      }<br>    }<br>  }<br>}</pre><p>The container must exist, be empty at first deployment, and not be shared with AzureWebJobsStorage &#39;s own container or another app&#39;s deployment.</p><p><strong>Note: each Function App requires its own dedicated deployment container.</strong> Two Flex Consumption apps cannot share the same blob container as their functionAppConfig.deployment.storage.value, even if they&#39;re otherwise unrelated. If a second app&#39;s serverFarmId or deployment path accidentally points at a container already in use by another app, deployments will silently overwrite or conflict with the other app&#39;s package, and both apps can end up serving inconsistent or broken code without a clear error pointing at the storage layer. When migrating multiple apps at once, name containers explicitly per app (e.g. deployment-package-&lt;app-name&gt;) rather than reusing a shared naming pattern.</p><p>storageAccountConnectionStringName only references the name of an App Setting - it does not create one. The setting must be added explicitly:</p><pre>resource MonitoringFunctionApp_appsettings &#39;Microsoft.Web/sites/config@2024-11-01&#39; = {<br>  parent: MonitoringFunctionApp<br>  name: &#39;appsettings&#39;<br>  properties: {<br>    AzureWebJobsStorage: StorageAccountConnectionString<br>    DEPLOYMENT_STORAGE_CONNECTION_STRING: StorageAccountConnectionString<br>    // ...other settings<br>  }<br>}</pre><p>Verify the setting deployed correctly (Azure CLI):</p><pre>az functionapp config appsettings list \<br>  --name &quot;&lt;function-app&gt;&quot; \<br>  --resource-group &quot;&lt;resource-group&gt;&quot; \<br>  --query &quot;[?name==&#39;DEPLOYMENT_STORAGE_CONNECTION_STRING&#39;]&quot;</pre><p>An empty [] result means the App Setting was never created - the app cannot authenticate to the deployment container, and deployments will fail even though the infrastructure appears to have deployed successfully.</p><h3>7. CI/CD Pipeline Updates</h3><p>This section applies specifically to Azure DevOps pipelines. Other CI/CD tools have the same underlying requirement — deploying to the Flex blob container rather than via zip-deploy — but the task/action configuration will differ.</p><p>Use Azure Functions Deploy task version 2 ( AzureFunctionApp@2). Version 1 assumes an older zip-deploy method that Flex Consumption doesn&#39;t support, and older builds of v2 that predate Flex Consumption support will also fail. This log line is informational, not an error:</p><blockquote>The Deployment Type option does not apply for Flex Consumption.</blockquote><p>isFlexConsumption: true is the input that actually routes the deployment through the Flex blob-container path - task version 2 alone is not sufficient without it.</p><pre>- task: AzureFunctionApp@2<br>  displayName: &#39;Deploy Azure Function App - Flex Consumption&#39;<br>  inputs:<br>    azureSubscription: &#39;$(azureServiceConnection)&#39;<br>    appType: &#39;functionAppLinux&#39;<br>    appName: &#39;$(functionAppName)&#39;<br>    package: &#39;$(Pipeline.Workspace)/drop/**/*.zip&#39;<br>    isFlexConsumption: true<br>    # deploymentMethod / Deployment Type is not used on Flex Consumption</pre><p>Note: the “Deployment Type does not apply” message and a 403 Ip Forbidden error (see below) can both appear in the same failed run. The first is harmless; don&#39;t let it mask the actual cause of a failure.</p><h3>8. (Optional) IP Restrictions for Deployment</h3><p>Skip this section if the Function App does not restrict inbound traffic by IP address.</p><p>If the SCM (deployment) endpoint is configured to inherit the main site’s IP restrictions, and those restrictions are scoped to specific regions, Microsoft-hosted Azure Pipelines agents — which don’t run from a fixed IP range or region — will be blocked with:</p><blockquote>Ip Forbidden (CODE: 403)</blockquote><p>Fix (Bicep, part of the site resource’s properties):</p><pre>scmIpSecurityRestrictionsUseMain: false<br>scmIpSecurityRestrictions: [<br>  {<br>    ipAddress: &#39;AzureCloud&#39;<br>    action: &#39;Allow&#39;<br>    tag: &#39;ServiceTag&#39;<br>    priority: 1000<br>    name: &#39;Allow AzureCloud for Microsoft-hosted pipeline agents&#39;<br>  }<br>  {<br>    ipAddress: &#39;Any&#39;<br>    action: &#39;Deny&#39;<br>    priority: 2147483647<br>    name: &#39;Deny all&#39;<br>  }<br>]<br>scmIpSecurityRestrictionsDefaultAction: &#39;Deny&#39;</pre><p>Note: the AzureCloud service tag allows traffic from anywhere in Azure, not just pipeline agents - there is no narrower published tag for this. Where that&#39;s too broad, a self-hosted agent with a known, fixed IP allowed instead is the tighter alternative.</p><p>Verify in the Portal under <strong>Function App → Networking → Access restriction</strong>, checking the SCM tab specifically — if it still reads “same restrictions as main site,” the change hasn’t taken effect.</p><h3>Validation Checklist</h3><ul><li>HTTP, Timer, Queue, and Service Bus triggers (plus Event Grid/Event Hub, if used)</li><li>Application Insights receiving telemetry</li><li>Managed Identity access to dependent resources</li><li>Storage connectivity — both AzureWebJobsStorage and the deployment container</li><li>Key Vault / App Configuration connectivity</li><li>Function execution logs</li><li>Scaling behaviour under load</li><li>Pipeline deploys without errors</li></ul><h3>Useful Commands</h3><p>Runtime check:</p><pre>az functionapp config show \<br>  --name &quot;&lt;function-app&gt;&quot; \<br>  --resource-group &quot;&lt;resource-group&gt;&quot; \<br>  --query linuxFxVersion</pre><p>Expected: DOTNET-ISOLATED|10.0</p><p>App settings:</p><pre>az functionapp config appsettings list \<br>  --name &quot;&lt;function-app&gt;&quot; \<br>  --resource-group &quot;&lt;resource-group&gt;&quot;</pre><p>Plan/status/kind:</p><pre>az functionapp config show \<br>  --name &quot;&lt;function-app&gt;&quot; \<br>  --resource-group &quot;&lt;resource-group&gt;&quot; \<br>  --query &quot;{sku:sku, status:status, kind:kind}&quot;</pre><p>Managed Identity role assignments:</p><pre>az role assignment list \<br>  --assignee &quot;&lt;managed-identity-id&gt;&quot; \<br>  --scope &quot;&lt;resource-id&gt;&quot; \<br>  --output table</pre><p>Update runtime version:</p><pre>az functionapp config set \<br>  --name &quot;&lt;function-app&gt;&quot; \<br>  --resource-group &quot;&lt;resource-group&gt;&quot; \<br>  --linux-fx-version &quot;DOTNET-ISOLATED|10.0&quot;</pre><h3>Future Considerations</h3><ul><li>Instance memory and maximumInstanceCount were set conservatively for a low-traffic monitoring workload; busier apps should revisit sizing after a period of production traffic on Flex.</li><li>Always-ready instances weren’t configured in this migration but are worth evaluating for functions sensitive to cold start.</li><li>The IP restriction workaround (AzureCloud on SCM) is broader than ideal; a self-hosted agent would allow tightening this further if the security baseline requires it.</li><li>A similar two-step approach is expected to apply to other apps still on Linux Consumption.</li><li>One Function App per Flex Consumption Plan</li></ul><h3>Conclusion</h3><p>Moving off Linux Consumption is a prerequisite for .NET 10, not an optional side step, but it changes more than the plan name suggests: runtime configuration moves out of App Settings and into functionAppConfig, deployment goes through a dedicated blob container instead of zip-deploy, default timeouts change, and IP-restricted apps need the SCM endpoint configured separately from the main site. None of these were individually hard to fix once identified - migrating the plan and the runtime as two separate, independently validated steps was what made the overall process manageable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bffb77e2ca58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/migrating-azure-functions-from-linux-consumption-to-flex-consumption-for-net-10-bffb77e2ca58">Upgrading Azure Functions to .NET 10: A Practical Flex Consumption Migration Guide</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Everyday Engineering Challenges to Useful Tech Stories]]></title>
            <link>https://medium.com/villa-plus-engineering/from-everyday-engineering-challenges-to-useful-tech-stories-6760c1bd0f02?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/6760c1bd0f02</guid>
            <category><![CDATA[engineering-culture]]></category>
            <category><![CDATA[agile-teams]]></category>
            <category><![CDATA[root-cause-analysis]]></category>
            <category><![CDATA[knowledge-sharing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Subhash S Nair]]></dc:creator>
            <pubDate>Wed, 22 Jul 2026 07:48:28 GMT</pubDate>
            <atom:updated>2026-07-22T07:48:29.516Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How we turned real engineering problems and solutions into useful knowledge-sharing stories at Villa Plus</em></p><h3>Overview</h3><p>At Villa Plus, our development teams solve meaningful technical problems every week. Some emerge through planned delivery, while others come from support tickets, production incidents, testing gaps, RCA findings or improvements to existing systems.</p><p>Once the work is completed, teams naturally move to the next priority. Yet the investigation, decisions and learning behind the solution can remain within a small group or disappear inside a closed ticket.</p><p>Our Tech Blog process was introduced to make those experiences visible and turn them into practical engineering knowledge that others could use.</p><h3>The Opportunity We Identified</h3><p>For developers, writing a blog can easily feel separate from day-to-day delivery. Even when they have solved a worthwhile problem, they may hesitate because they believe the topic must be completely new, highly technical or written as a polished article by one person.</p><p>On the ground, the content already existed. Developers were diagnosing production issues, improving system behaviour, finding missing test scenarios and documenting root causes. The real gap was visibility: useful problems and solutions were present across recent work, but they were not always recognised as stories worth sharing.</p><h3>What We Did</h3><p>We created simple visibility around recent stories, tickets, RCA findings and technical improvements so teams could review their work and identify experiences worth sharing.</p><p>The discussion stayed practical: Was the problem unusual? Did it require deeper investigation? Did the RCA reveal something useful? Could the learning help another developer or team?</p><p>It also brought forward the learnings from challenges faced during development work-what did not work as expected, how the team adapted and what could be improved next time.</p><p>This made blogging a natural extension of delivery. A well-documented ticket, RCA or technical improvement could become the starting point for a useful story.</p><p>The writing format was kept simple:</p><p><strong>The Problem → Our Approach → The Solution → What We Learned</strong></p><p>The strongest topics came from real Villa Plus experiences, including production issues, business logic improvements, performance gaps, testing findings, root-cause analysis and repeat prevention.</p><p>We also moved beyond the idea of one developer writing alone. Developers could write in pairs, reducing hesitation, sharing the effort and producing more balanced blogs. Drafts were then technically reviewed, refined and tracked through to publication.</p><h3>How It Is Benefiting Us</h3><p>This approach has helped us publish more than 30 unique technical blogs based on real engineering work.</p><p>More importantly, it has changed how we view everyday delivery. A support ticket can carry a lesson about testing or system behaviour. An RCA can reveal a problem worth exploring. A production incident can become a story about investigation and prevention. A technical improvement can become reusable knowledge for another team.</p><p>Our developers also gain a way to explain the thinking, collaboration and persistence behind the final solution — not only the completed output. Pair writing has widened participation and enabled more people to contribute, even when they would not naturally see themselves as blog writers. Because the topics come from our real work at Villa Plus, the content remains practical, relevant and authentic.</p><h3>Conclusion</h3><p>Useful technical content does not always begin with a groundbreaking technology or a completely new idea. Often, the strongest stories are already present in our everyday engineering work.</p><p>At Villa Plus, we did not add blogging as a separate responsibility. We created a simple habit that makes recent work visible, helps our developers recognise valuable learning and gives them a practical way to shape and share it.</p><p>The outcome is straightforward: real problems, practical solutions and useful knowledge that can travel beyond the team that first solved them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6760c1bd0f02" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/from-everyday-engineering-challenges-to-useful-tech-stories-6760c1bd0f02">From Everyday Engineering Challenges to Useful Tech Stories</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating Azure Functions to OpenTelemetry logging]]></title>
            <link>https://medium.com/villa-plus-engineering/migrating-azure-functions-to-opentelemetry-loging-d7b1eb3d5d94?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/d7b1eb3d5d94</guid>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[azure-app-insights]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <dc:creator><![CDATA[Ihar Miadzelets]]></dc:creator>
            <pubDate>Mon, 25 May 2026 05:21:23 GMT</pubDate>
            <atom:updated>2026-09-16T11:32:28.519Z</atom:updated>
            <content:encoded><![CDATA[<p>This article outlines the migration of observability and logging across Azure Functions, focusing on the transition from Application Insights to a newer telemetry approach using OpenTelemetry. It highlights key configuration considerations and compatibility issues encountered during upgrades, and presents OpenTelemetry as the recommended direction, alongside continued general support for Application Insights v3.</p><p>The upgrade from Application Insights v2 to v3 packages in Azure Functions can fail with a runtime type loading error: <em>Could not load type ‘Microsoft.ApplicationInsights.Extensibility.ITelemetryInitializer’</em> (caused by version mismatches or dependency graph incompatibilities with the Functions runtime). As a result, the recommended solution from Microsoft engineers is to migrate Azure Functions observability to OpenTelemetry.</p><p>Furthermore, as noted above, OpenTelemetry has become the primary mechanism for exporting logs and traces to the Application Insights backend.</p><h3>1. Package Updates</h3><p>Required packages (from csproj files, versions are actual for the moment of writing)</p><pre>&lt;PackageReference Include=&quot;Azure.Monitor.OpenTelemetry.Exporter&quot; Version=&quot;1.8.0&quot; /&gt;  <br>&lt;PackageReference Include=&quot;OpenTelemetry.Extensions.Hosting&quot; Version=&quot;1.15.3&quot; /&gt;  <br>&lt;PackageReference Include=&quot;Microsoft.Azure.Functions.Worker.OpenTelemetry&quot; Version=&quot;1.2.0&quot; /&gt;</pre><p>Optional packages (depending on instrumentation that should be logged)</p><pre>&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.SqlClient&quot; Version=&quot;1.15.2&quot; /&gt;  <br>&lt;PackageReference Include=&quot;OpenTelemetry.Instrumentation.Http&quot; Version=&quot;1.15.1&quot; /&gt;</pre><p>Remove old Application Insights packages <em>Microsoft.ApplicationInsights*, Microsoft.Azure.WebJobs.Logging.ApplicationInsights, etc.</em></p><h3>2. Function Startup Configuration</h3><p>The configuration differs depending on the function startup approach. The modern approach allows additional OpenTelemetry configuration, but there is no confirmed working solution for loading environment-dependent custom config files (like appsettings.Test.json) and using these values immediately in startup code. The older approach still works with isolated functions and .NET 8.</p><h4>Modern approach startup file like:</h4><pre>var builder = FunctionsApplication.CreateBuilder(args);<br>...<br>await builder.Build().RunAsync();</pre><p>OpenTelemetry config:</p><pre>builder.Logging.AddOpenTelemetry();</pre><h4>Classic startup model code:</h4><pre>public class Program {<br>    public static async Task Main(string[] args) {<br>        var host = new HostBuilder()<br>            .ConfigureServices(services =&gt; {<br>                ...<br>            })<br>            .Build();<br>        <br>        await host.RunAsync();<br>    }<br>}</pre><p>Logging configuration:</p><pre>services.AddLogging(logging =&gt; logging.AddOpenTelemetry());</pre><p>Some parameters can be applied when initializing OpenTelemetry:</p><pre>services.AddLogging(logging =&gt; logging.AddOpenTelemetry(options =&gt;<br>{<br>    options.IncludeFormattedMessage = true;<br>    options.IncludeScopes = true;<br>}));</pre><h3>3. OpenTelemetry Tracing Setup, Sources, New Sampling Settings</h3><p>Trace configuration depends on registered sources and instrumentations. This is a key difference from Application Insights telemetry: in OpenTelemetry only explicitly registered sources are collected. Each ‘.Add..’ line after ‘.WithTracing(tracing =&gt; tracing’ represent a tracing source: SQL, HTTP, Cosmos DB, Servcie Bus</p><pre>builder.Services<br>    .AddOpenTelemetry()<br>    .WithTracing(tracing =&gt; tracing<br>        .AddSqlClientInstrumentation(options =&gt; options.RecordException = true) // SQL queries with additional parameter<br>        .AddHttpClientInstrumentation()          // HTTP dependencies<br>        .AddSource(&quot;Azure.Cosmos.Operation&quot;)     // Cosmos SDK activity<br>        .AddSource(&quot;Azure.Messaging.ServiceBus&quot;) // Service Bus activity<br>        .SetSampler(new AlwaysOnSampler())   // collect all traces in SDK (equivalent to disabled sampling in AppInsights)<br>    )<br>    .UseFunctionsWorkerDefaults()<br>    .UseAzureMonitorExporter(options =&gt; options.SamplingRatio = 1); // SamplingRatio = 1 equals to no sampling at exporter level</pre><p>Note: The code above shows the configuration that imitates Application Insights with sampling disabled, meaning all logs are publishing. OTel ‘AlwaysOnSampler()’ and ‘SamplingRatio = 1’ do the trick. To configure sampling differently check for other samplers and set SamplingRatio to the float value between 0 and 1 representing the ratio of result records.</p><h3>4. Log Levels, Old Sampling Settings</h3><p>Application Insights sampling configuration is not applicable in the old form and is ignored in OpenTelemetry, the following config can be removed (typically exists in host.json):</p><pre>&quot;logging&quot;: {<br>  &quot;applicationInsights&quot;: {<br>    &quot;samplingSettings&quot;: {<br>      &quot;isEnabled&quot;: false,<br>      &quot;excludedTypes&quot;: &quot;Request&quot;<br>    }<br>  }<br>}</pre><p>Note: there is no direct approach for filtering logs, such as excluding telemetry types like in AppInsights. To implement filtering, custom code should be added to intercept and filter out traces by unnecessary attribute values.</p><p>Infrastructure/host logging levels can be set like (host.json):</p><pre>&quot;logging&quot;: {<br>  &quot;logLevel&quot;: {<br>    &quot;default&quot;: &quot;Information&quot;<br>  }<br>}</pre><p>Function/runtime logging levels are also configurable (appsettings.json):</p><pre>{<br>  &quot;Logging&quot;: {<br>    &quot;LogLevel&quot;: {<br>      &quot;Default&quot;: &quot;Debug&quot;,<br>      &quot;System&quot;: &quot;Information&quot;,<br>      &quot;Microsoft&quot;: &quot;Information&quot;<br>    }<br>  }<br>}</pre><p>Be aware that LogLevel in host and appsettings apply to different layers of telemetry/log providers.</p><h3>5. ILogger Abstraction, Telemetry Publishing</h3><p>Domain-level ILogger/Logger wrappers are no longer required. Prefer injecting of `ILogger&lt;TService&gt;` from Microsoft directly into Functions.</p><p>Note: Typed logger instance ensures `Category` in logs is filled from `TService` name, improving filtering possibilities in Azure Monitor.</p><h4>Optional approach</h4><p>To reduce migration impact, a compatibility wrapper can be used, replacing old approach where Logger was required to decorate writing to TelemetryClient. For OpenTelemetry it can be introduced like:</p><pre>public class VpLogger&lt;TService&gt;(ILogger&lt;TService&gt; logger) : ILogger where TService : class<br>{<br>  public void LogException(Exception ex, IDictionary&lt;string, string&gt; properties = null) =&gt; ...<br>  public void LogTrace(string trace, IDictionary&lt;string, string&gt; properties = null) =&gt; ...</pre><p>Registration:</p><pre>services.AddTransient&lt;ILogger, VpLogger&lt;YourFunction&gt;&gt;();</pre><h4>Dependency conflict handling</h4><p>Some packages introduce their own ILogger implementation with dependency to TelemetryClient. This must be overridden explicitly in function:</p><pre>services.RemoveAll&lt;EventBus.ILogger&gt;();<br>services.AddSingleton&lt;EventBus.ILogger, FunctionEventBusLogger&gt;();</pre><h3>6. Traces and CustomEvents Logging in OpenTelemetry</h3><p>Traces are logged as Information in code:</p><pre>logger.LogInformation(trace, properties);</pre><p>Writing CustomEvent logs requires adding the standard property &quot;microsoft.custom_event.name&quot; with the event type value:</p><pre>private const string OpenTelemetryCustomEventPropertyName = &quot;microsoft.custom_event.name&quot;;<br><br>public void LogCustomEvent(string eventName, IDictionary&lt;string, string&gt; properties = null)<br>{<br>    properties = properties ?? new Dictionary&lt;string, string&gt;();<br>    properties.Add(OpenTelemetryCustomEventPropertyName, eventName);<br>    logger.LogInformation($&quot;{{{string.Join(&quot;} {&quot;, properties.Keys)}}}&quot;, properties.Values.ToArray());<br>}</pre><h3>7. Resolving of versions conflict when using DefaultAzureCredential()</h3><p>Authorizing some Azure services in our solution requires initialization of the DefaultAzureCredential() class. With newer Function and Telemetry package versions, this introduces conflicts due to mismatched transient dependency versions. This is expected to be resolved in future Azure SDK releases. For now, the following workaround can be applied by explicitly including the required packages in function project:</p><pre>&lt;PackageReference Include=&quot;Azure.Core&quot; Version=&quot;1.56.0&quot; /&gt;<br>&lt;PackageReference Include=&quot;Azure.Identity&quot; Version=&quot;1.21.0&quot; /&gt;</pre><h3>App Services migration to Application Insights v3</h3><p>Despite the recommendation to migrate logging to OpenTelemetry, Azure .NET App Services do not experience the same compilation issue observed in Azure Functions. Application Insights v3 can still be used for App Service workloads when migrating from v2. But, as mentioned in previous part, OpenTelemetry is internally used by AppInsights v3 even if you not configure OTel in code.</p><p>The only important change required apart from updating dependencies is Application Insights configuration change in app startup:</p><pre>services.AddApplicationInsightsTelemetry(options =&gt;<br>{<br>    options.SamplingRatio = 1;<br>    options.EnableTraceBasedLogsSampler = false;<br>    options.Credential =<br>        _webHostEnvironment.IsDevelopment()<br>            ? new DefaultAzureCredential()<br>            : new ManagedIdentityCredential();<br>});</pre><p>The sampling configuration has changed. The meaning of SamplingRatio is explained in the Function updates section above, the Azure packages conflict can be worked around by including packages directly.</p><h3>Reducing custom metrics volume</h3><p>OpenTelemetry generates more telemetry records than the previous Application Insights implementation, even when using similar log levels. The increase is especially noticeable for custom metrics that can be observed in Azure Metrics monitoring pages, in our case the most popular are HTTP request metrics generated by the function host and .NET-related metrics.</p><p>Moreover, the issue is also present for App Services migrated to Application Insights v3 without a direct migration to OpenTelemetry. It appears that some Application Insights v3 components use OpenTelemetry internally, even when the application is configured using the traditional Application Insights approach without explicitly referencing OpenTelemetry in the code.</p><p>For some reason the different filtering approaches worked for App Services migrated to Application Insights v3 and Functions with OpenTelemetry.</p><h4>Disable new custom metrics for App Services</h4><p>The following filter can be added to the startup code of the app:</p><pre>services<br>  .AddApplicationInsightsTelemetry(options =&gt; { … })<br>  .ConfigureOpenTelemetryMeterProvider((sp, meterBuilder) =&gt;<br>  {<br>    meterBuilder.AddView(instrumentName: &quot;http.client.*&quot;, MetricStreamConfiguration.Drop);<br>    meterBuilder.AddView(instrumentName: &quot;http.server.*&quot;, MetricStreamConfiguration.Drop);<br>  });</pre><p>These “http.client.*” and “http.server.*” filters reduced the amount of custom metrics sent by AppServices by about 95% in our case.</p><h4>Disable new custom metrics for Azure Functions</h4><p>Filtering is configured by adding Transformation Data Collection Rule to the AppMetrics table of the Application Insights.</p><p>This can be done in the Azure Portal: go to the appropriate Log Analytics workspace -&gt; Tables -&gt; right click on AppMetrics table -&gt; Edit Transformation, then in the query editor paste the following kusto filter and save transformation rule</p><pre>source<br>| where Name !contains &#39;azure.functions.health_check.reports&#39;<br>    and Name !contains &#39;kestrel.&#39;<br>    and Name !contains &#39;process.runtime.dotnet&#39;<br>    and Name !contains &#39;process.cpu.&#39;</pre><p>These filters significantly reduced the amount of new custom metrics sent by Azure Functions.</p><p><strong>Important</strong>: When applying these filters via provisioning with ARM templates/Bicep, the important thing is to assign this transformation rule in separate step after the Application Insight Workspace and the Transformation Rule are created.</p><p>In bicep this is achieved by separate modules applied in order, where the first module defines the AppLication Insight Workspace and the Transformation:</p><pre>param AppInsightSettings object<br><br>resource Workspace &#39;Microsoft.OperationalInsights/workspaces@2021-12-01-preview&#39; = {<br>..<br>}<br><br>resource CustomMetricsDataCollectionRule &#39;Microsoft.Insights/dataCollectionRules@2023-03-11&#39; = {<br>  name: AppInsightSettings.customMetricsFilterRuleName<br>  location: AppInsightSettings.location<br>  kind: &#39;WorkspaceTransforms&#39;<br>  properties: {<br>    destinations: {<br>      logAnalytics: [<br>        {<br>          workspaceResourceId: resourceId(&#39;Microsoft.OperationalInsights/workspaces&#39;, AppInsightSettings.workspaceName)<br>          name: &#39;dcrtransformationname&#39;<br>        }<br>      ]<br>    }<br>    dataSources: {}<br>    dataFlows: [<br>      {<br>        streams: [<br>          &#39;Microsoft-Table-AppMetrics&#39;<br>        ]<br>        destinations: [<br>          &#39;dcrtransformationname&#39;<br>        ]<br>        transformKql: &#39;source | where Name !contains &quot;azure.functions.health_check.reports&quot; and Name !contains &quot;kestrel.&quot; and Name !contains &quot;process.runtime.dotnet&quot; and Name !contains &quot;process.cpu.&quot;&#39;<br>      }<br>    ]<br>  }<br>}<br><br>output DataCollectionRuleId = CustomMetricsDataCollectionRule.id</pre><p>The second module then applies the transformation rule to the workspace:</p><pre>param AppInsightSettings object<br>param DataCollectionRuleId string<br><br>resource Workspace &#39;Microsoft.OperationalInsights/workspaces@2021-12-01-preview&#39; existing = {<br>  name: AppInsightSettings.workspaceName<br>}<br><br>resource workspaceUpdate &#39;Microsoft.OperationalInsights/workspaces@2022-10-01&#39; = {<br>  name: Workspace.name<br>  location: AppInsightSettings.location<br>  properties: {<br>    defaultDataCollectionRuleResourceId: DataCollectionRuleId<br>  }<br>}</pre><p>For the ARM templates, the problem of requiring 2 steps can be solved by nested deployments, so the template can look like:</p><pre>&quot;parameters&quot;: {<br>  &quot;appInsightsWorkspaceName&quot;: {<br>    &quot;type&quot;: &quot;string&quot;<br>  },<br>  &quot;customMetricsFilterRuleName&quot;: {<br>    &quot;type&quot;: &quot;string&quot;<br>  }<br>},<br>&quot;resources&quot;: [<br>  {<br>    &quot;type&quot;: &quot;Microsoft.OperationalInsights/workspaces&quot;<br>    ...<br>  },<br>  {<br>    &quot;apiVersion&quot;: &quot;2023-03-11&quot;,<br>    &quot;name&quot;: &quot;[parameters(&#39;customMetricsFilterRuleName&#39;)]&quot;,<br>    &quot;type&quot;: &quot;Microsoft.Insights/dataCollectionRules&quot;,<br>    &quot;location&quot;: &quot;northeurope&quot;,<br>    &quot;kind&quot;: &quot;WorkspaceTransforms&quot;,<br>    &quot;properties&quot;: {<br>      &quot;destinations&quot;: {<br>        &quot;logAnalytics&quot;: [<br>          {<br>            &quot;workspaceResourceId&quot;: &quot;[resourceId(&#39;Microsoft.OperationalInsights/workspaces&#39;, parameters(&#39;appInsightsWorkspaceName&#39;))]&quot;,<br>            &quot;name&quot;: &quot;dcrtransformationname&quot;<br>          }<br>        ]<br>      },<br>      &quot;dataSources&quot;: {},<br>      &quot;dataFlows&quot;: [<br>        {<br>          &quot;streams&quot;: [<br>            &quot;Microsoft-Table-AppMetrics&quot;<br>          ],<br>          &quot;destinations&quot;: [<br>            &quot;dcrtransformationname&quot;<br>          ],<br>          &quot;transformKql&quot;: &quot;source | where Name !contains &#39;azure.functions.health_check.reports&#39; and Name !contains &#39;kestrel.&#39; and Name !contains &#39;process.runtime.dotnet&#39; and Name !contains &#39;process.cpu.&#39;&quot;<br>        }<br>      ]<br>    }<br>  },<br>  {<br>    &quot;type&quot;: &quot;Microsoft.Resources/deployments&quot;,<br>    &quot;apiVersion&quot;: &quot;2020-10-01&quot;,<br>    &quot;name&quot;: &quot;GetAppSettings&quot;,<br>    &quot;dependsOn&quot;: [<br>      &quot;[resourceId(&#39;Microsoft.Insights/dataCollectionRules&#39;, parameters(&#39;customMetricsFilterRuleName&#39;))]&quot;<br>    ],<br>    &quot;properties&quot;: {<br>      &quot;mode&quot;: &quot;Incremental&quot;,<br>      &quot;expressionEvaluationOptions&quot;: {<br>        &quot;scope&quot;: &quot;Inner&quot;<br>      },<br>      &quot;parameters&quot;: {<br>        &quot;appInsightsWorkspaceNameInner&quot;: {<br>          &quot;value&quot;: &quot;[parameters(&#39;appInsightsWorkspaceName&#39;)]&quot;<br>        },<br>        &quot;customMetricsFilterRuleNameInner&quot;: {<br>          &quot;value&quot;: &quot;[resourceId(&#39;Microsoft.Insights/dataCollectionRules&#39;, parameters(&#39;customMetricsFilterRuleName&#39;))]&quot;<br>        }<br>      },<br>      &quot;template&quot;: {<br>        &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,<br>        &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,<br>        &quot;parameters&quot;: {<br>          &quot;customMetricsFilterRuleNameInner&quot;: {<br>            &quot;type&quot;: &quot;string&quot;<br>          }<br>        },<br>        &quot;resources&quot;: [<br>          {<br>            &quot;type&quot;: &quot;Microsoft.OperationalInsights/workspaces&quot;,<br>            &quot;apiVersion&quot;: &quot;2023-09-01&quot;,<br>            &quot;name&quot;: &quot;[parameters(&#39;appInsightsWorkspaceNameInner&#39;)]&quot;,<br>            &quot;location&quot;: &quot;northeurope&quot;,<br>            &quot;properties&quot;: {<br>              &quot;defaultDataCollectionRuleResourceId&quot;: &quot;[parameters(&#39;customMetricsFilterRuleNameInner&#39;)]&quot;<br>            }<br>          }<br>        ]<br>      }<br>    }<br>  }<br>]</pre><h4>Additional common configuration</h4><p>These approaches arerecommended in some articles, but had no visible effect in our case</p><p>App/Function environment variables:</p><pre>OTEL_METRICS_EXPORTER=None<br>OTEL_DOTNET_AUTO_METRICS_ENABLED=false</pre><p>Host logging configuration (host.json):</p><p>This configuration reduces infrastructure and framework-generated log records. Additional filtering may still be required depending on enabled instrumentations and application-specific logging requirements.</p><pre>&quot;logging&quot;: {<br>  &quot;logLevel&quot;: {<br>    &quot;default&quot;: &quot;Warning&quot;,<br>    &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot;,<br>    &quot;Host.Aggregator&quot;: &quot;Warning&quot;<br>  },<br>  &quot;OpenTelemetry&quot;: {<br>    &quot;logLevel&quot;: {<br>      &quot;default&quot;: &quot;Warning&quot;,<br>      &quot;Microsoft.AspNetCore&quot;: &quot;Warning&quot;<br>    }<br>  }<br>}</pre><h4>Monitoring of telemetry volume and custom metrics.</h4><p>To check the change in the amount of metrics, traces after migration, the following kusto queries may be used in Azure Application Insigths -&gt;Logs page.</p><p>Total usage of AppInsight (per item types: dependencies, traces, custom metrics, etc.):</p><pre>union *<br>| summarize ingestedGB=sum(_BilledSize) / 1.E6 by itemType, bin(timestamp, 1d)<br>| render areachart</pre><p>Custom metrics per type and service:</p><pre>customMetrics<br>| summarize count(), billedMB=sum(_BilledSize)/1e6 by cloud_RoleName, name<br>| order by count_ desc</pre><h3><strong>Future Considerations</strong></h3><p>The provided configuration represents a default, near-minimal baseline intended to support a stable migration. Further work is expected to refine and stabilize observability behavior.</p><ul><li>Some telemetry that was previously captured automatically may need to be explicitly configured, requiring additional instrumentation to restore full coverage.</li><li>Remove the existing ILogging abstraction</li><li>A similar migration approach is expected for Azure App Services.</li><li>Future packages updates may allow removal of current workarounds and further simplification of the setup.</li></ul><h3><strong>Conclusion</strong></h3><p>Migrating observability in Azure workloads requires careful consideration of runtime compatibility and SDK dependencies. While Application Insights v3 remains a viable option for App Services, Azure Functions benefit from adopting OpenTelemetry as the primary telemetry pipeline, ensuring improved compatibility, extensibility, and alignment with modern observability standards.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7b1eb3d5d94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/migrating-azure-functions-to-opentelemetry-loging-d7b1eb3d5d94">Migrating Azure Functions to OpenTelemetry logging</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Generic Audit Table for All Database Operations]]></title>
            <link>https://medium.com/villa-plus-engineering/building-a-generic-audit-table-for-all-database-operations-99cf1cfa18c5?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/99cf1cfa18c5</guid>
            <category><![CDATA[audit-logging-system]]></category>
            <category><![CDATA[generic-audit-table-sql]]></category>
            <category><![CDATA[build-generic-audit-table]]></category>
            <category><![CDATA[centralized-audit-logging]]></category>
            <dc:creator><![CDATA[Aishwarya Pansare]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 05:06:01 GMT</pubDate>
            <atom:updated>2026-04-30T05:06:00.454Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern applications, tracking data changes is just as important as storing the data itself. Whether it’s a small app or a large system, knowing what changed, when it changed, and who made the change helps with debugging, accountability, and meeting compliance needs.</p><p>There are different ways to track data changes, such as Application Insights or system-versioned temporal tables. However, these approaches have some limitations. For example, in Application Insights, understanding a complete change often requires joining multiple logs or tables, which can be complex. Also, while these methods can show what data changed over time, they usually don’t clearly capture who performed the action.</p><p>That’s why using a custom audit table becomes important. It gives you full control to track not just the data changes, but also the user responsible for those changes, all in one place.</p><p><strong>What is an Audit Table?</strong></p><p>An audit table stores a history of important actions performed on your system’s data, typically Create, Update, and Delete operations.</p><p>A well-designed audit system should answer:</p><ul><li>Who performed the action?</li><li>What changed?</li><li>When did it happen?</li><li>What was the previous vs. new state?</li></ul><p><strong>How an Audit Table Works</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*7aEqamYnywOxAjRfd5buIg.jpeg" /></figure><p><strong>Step-by-step flow:</strong></p><ol><li>A user performs an action (Create / Update / Delete)</li><li>The application processes the request</li><li>A database transaction begins</li><li>Two operations happen <strong>together</strong>:</li></ol><ul><li>Data is modified in the main table</li><li>An audit record is inserted into the audit table</li></ul><p>5. The transaction commits → both succeed or both fail</p><p><strong>Designing the Audit Table</strong></p><p>A flexible and generic audit table should be capable of handling records across multiple entities while remaining simple, scalable, and easy to query.</p><p>Here is a clean and effective baseline structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*19KJBEQya1SHArFGWBB7Dw.png" /></figure><p><strong>Field Breakdown</strong></p><ul><li><strong>Id</strong>: Unique identifier for each audit record</li><li><strong>EntityName</strong>: Name of the main table or entity where the operation was performed (e.g., User, Order, Product)</li><li><strong>EntityID</strong>: Identifier of the record in the main table</li><li><strong>Details</strong>: JSON representation of the latest state of the entity</li><li><strong>ActionedBy</strong>: JSON containing user details and timestamp of the action</li></ul><p><strong>Why JSON for Details and ActionedBy?</strong></p><p>Using JSON provides flexibility and scalability:</p><ul><li>Store complex object structures without frequent schema changes</li><li>Easily serialize and deserialize application objects</li><li>Adapt to evolving data models without database redesign</li><li>No indexing is required</li></ul><p><strong>Implementing Audit Logging in Code</strong></p><p>To ensure consistency, audit logging must be part of the <strong>same database transaction</strong> as the main operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_-KI68nZhdPCp7kgpKxTA.png" /></figure><p><strong>Key Takeaways from the Code</strong></p><ul><li><strong>Transactional Integrity</strong><br> Audit and data operations succeed or fail together</li><li><strong>Batch Processing</strong><br> Efficiently handles multiple records in one operation</li><li><strong>Reusable Design</strong><br> A generic audit model works across different entities</li></ul><p><strong>Conclusion</strong></p><p>A well-designed audit table is a cornerstone of robust application architecture. It improves visibility into system operations while enhancing reliability, traceability, and trust.</p><p>By implementing a <strong>generic, transaction-safe audit mechanism</strong>, you can scale your application confidently while maintaining full control over your data history.</p><p>Whether you are debugging production issues or meeting compliance requirements, an audit trail ensures you are never in the dark about what happened in your system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99cf1cfa18c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/building-a-generic-audit-table-for-all-database-operations-99cf1cfa18c5">Building a Generic Audit Table for All Database Operations</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Filtering out Bot traffic from Analytics]]></title>
            <link>https://medium.com/villa-plus-engineering/filtering-out-bot-traffic-from-analytics-3924aa4c35c1?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/3924aa4c35c1</guid>
            <category><![CDATA[data-quality]]></category>
            <category><![CDATA[web-analytics]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[bot-traffic-exclusion]]></category>
            <category><![CDATA[google-analytics-clean-up]]></category>
            <dc:creator><![CDATA[Arti Jeurkar]]></dc:creator>
            <pubDate>Fri, 20 Mar 2026 06:38:09 GMT</pubDate>
            <atom:updated>2026-03-20T06:38:08.433Z</atom:updated>
            <content:encoded><![CDATA[<p>Villa Plus believes in Data-driven decisions for the business. We highly rely on the Google analytics to understand user behaviour, measure performance, and continuously improve our platform. When the data is accurate, it gives us confidence to act. But when it isn’t, even small discrepancy can lead to the wrong conclusions.</p><p>While studying the user behaviour using data in Google Analytics, we noticed something didn’t add up -</p><p>1. Many hits to the page which had long URLs directly did not seem to be typical user behaviour</p><p>2. The user engagement on the page was quite less and bounce rate was very high - a pattern that’s unusual</p><p>On the surface, everything looked healthy. A deeper dive told a different story. Upon further comparing the requests with another platform (Azure Application insights), it was found that a significant portion of the traffic being logged in Google analytics wasn’t coming from real users at all - it was bot traffic. This was obviously distorting the data analysis.</p><p>And despite Google analytics built-in bot filtering, this traffic was still making its way into our reports.</p><p>In this post, we’ll walk through how we identified the issue, why default Google analytics settings weren’t sufficient, and the approach we used to exclude bot traffic and restore confidence in our analytics data.</p><h3><strong>Google analytics settings weren’t sufficient</strong></h3><p>By default, Google Analytics automatically excludes traffic from known bots and spiders using industry-maintained lists such as IAB (Interactive Advertising Bureau).</p><p>Google analytics only filters:</p><ul><li>Known bots</li><li>Bots that identify themselves properly</li><li>Bots included in the IAB list</li></ul><p>This means the following can still bypass Google analytics filters:</p><ul><li>Newly created bots</li><li>Sophisticated scraping tools</li><li>Spam scripts that disguise themselves as browsers</li><li>Crawlers that do not appear in the IAB list</li></ul><p>As a result, these requests were still being logged in Google analytics.</p><h3><strong>Our Approach to Exclude Bot Traffic</strong></h3><p>Solution implemented was to have our own code to identify whether the request is from Bot and if so, do not initialize the Google analytics code. This sounds simple but the main challenge was maintaining the list of Bots which is explained further in blog</p><p>Identify Bot request- We can identify the Bot request using the user agent. A user agent is a text string sent by your browser or script during an HTTP request to identify the client’s software and operating environment to the server. To identify a bot request using the User-Agent (UA) header, we primarily look for specific strings or patterns that indicate automated traffic</p><p><strong>Google:</strong> Googlebot, AdsBot-Google, Mediapartners-Google, etc.</p><p><strong>Microsoft:</strong> bingbot, AdIdxBot, MicrosoftPreview</p><p>Here is the code to maintain a list of Bot patterns and then check if the user agent contains any pattern from the list.</p><p>BotPatterns.cs</p><pre>public static class BotPatterns<br>{<br>    public static readonly string[] Patterns  = [    &quot;Googlebot/&quot;,    &quot;Googlebot-Mobile&quot;,    &quot;Googlebot-Image&quot;,    &quot;Googlebot-News&quot;,    &quot;Googlebot-Video&quot;,    &quot;AdsBot-Google([^-]|$)&quot;,    &quot;AdsBot-Google-Mobile&quot;,    &quot;Feedfetcher-Google&quot;,    &quot;Mediapartners-Google&quot;,    &quot;Mediapartners (Googlebot)&quot;,    &quot;APIs-Google&quot;,    &quot;Google-InspectionTool&quot;,    &quot;Storebot-Google&quot;,    &quot;GoogleOther&quot;,    &quot;bingbot&quot;,    &quot;Slurp&quot;,    &quot;[wW]get&quot;,    &quot;LinkedInBot&quot;,    &quot;Python-urllib&quot;,    &quot;python-requests&quot;,    &quot;aiohttp&quot;,    &quot;httpx&quot;,    &quot;libwww-perl&quot;,    &quot;httpunit&quot;,    &quot;Nutch&quot;,    &quot;Go-http-client&quot;,    &quot;phpcrawl&quot;,    &quot;msnbot&quot;,    &quot;jyxobot&quot;,    &quot;FAST-WebCrawler&quot;,    &quot;FAST Enterprise Crawler&quot;,    &quot;BIGLOTRON&quot;,    &quot;Teoma&quot;,    &quot;convera&quot;,    &quot;seekbot&quot;,    &quot;Gigabot&quot;,    &quot;Gigablast&quot;,    &quot;exabot&quot;,    &quot;ia_archiver&quot;,    &quot;GingerCrawler&quot;,    &quot;webmon &quot;,    &quot;HTTrack&quot;,    &quot;grub.org&quot;,    &quot;UsineNouvelleCrawler&quot;,    &quot;antibot&quot;,    &quot;netresearchserver&quot;,    &quot;speedy&quot;,    &quot;fluffy&quot;,    &quot;findlink&quot;,    &quot;msrbot&quot;,    &quot;panscient&quot;,    &quot;yacybot&quot;,    &quot;AISearchBot&quot;,    &quot;ips-agent&quot;,    &quot;tagoobot&quot;,    &quot;MJ12bot&quot;,    &quot;woriobot&quot;,    &quot;yanga&quot;,    &quot;buzzbot&quot;,    &quot;mlbot&quot;,    &quot;yandex.com/bots&quot;,    &quot;purebot&quot;,    &quot;Linguee Bot&quot;,    &quot;CyberPatrol&quot;,    &quot;voilabot&quot;,    &quot;Baiduspider&quot;,    &quot;citeseerxbot&quot;,    &quot;spbot&quot;,    &quot;twengabot&quot;,    &quot;postrank&quot;,    &quot;Turnitin&quot;,    &quot;scribdbot&quot;,    &quot;page2rss&quot;,    &quot;sitebot&quot;,    &quot;linkdex&quot;,    &quot;Adidxbot&quot;,    &quot;ezooms&quot;,    &quot;dotbot&quot;,    &quot;Mail.RU_Bot&quot;,    &quot;discobot&quot;,    &quot;heritrix&quot;,    &quot;findthatfile&quot;,    &quot;europarchive.org&quot;,    &quot;NerdByNature.Bot&quot;,    &quot;(sistrix|SISTRIX) [cC]rawler&quot;,    &quot;Ahrefs(Bot|SiteAudit)&quot;,    &quot;fuelbot&quot;,    &quot;CrunchBot&quot;,    &quot;IndeedBot&quot;,    &quot;mappydata&quot;,    &quot;woobot&quot;,    &quot;ZoominfoBot&quot;,    &quot;PrivacyAwareBot&quot;,    &quot;Multiviewbot&quot;,    &quot;SWIMGBot&quot;,    &quot;Grobbot&quot;,    &quot;eright&quot;,    &quot;Apercite&quot;,    &quot;semanticbot&quot;,    &quot;Aboundex&quot;,    &quot;domaincrawler&quot;,    &quot;wbsearchbot&quot;,    &quot;summify&quot;,    &quot;CCBot&quot;,    &quot;edisterbot&quot;,    &quot;SeznamBot&quot;,    &quot;ec2linkfinder&quot;,    &quot;gslfbot&quot;,    &quot;aiHitBot&quot;,    &quot;intelium_bot&quot;,    &quot;facebookexternalhit&quot;,    &quot;Yeti&quot;,    &quot;RetrevoPageAnalyzer&quot;,    &quot;lb-spider&quot;,    &quot;Sogou&quot;,    &quot;lssbot&quot;,    &quot;careerbot&quot;,    &quot;wotbox&quot;,    &quot;wocbot&quot;,    &quot;ichiro&quot;,    &quot;DuckDuckBot&quot;,    &quot;lssrocketcrawler&quot;,    &quot;drupact&quot;,    &quot;webcompanycrawler&quot;,    &quot;acoonbot&quot;,    &quot;openindexspider&quot;,    &quot;gnam gnam spider&quot;,    &quot;web-archive-net.com.bot&quot;,    &quot;backlinkcrawler&quot;,    &quot;coccoc&quot;,    &quot;integromedb&quot;,    &quot;content crawler spider&quot;,    &quot;toplistbot&quot;,    &quot;it2media-domain-crawler&quot;,    &quot;ip-web-crawler.com&quot;,    &quot;siteexplorer.info&quot;,    &quot;elisabot&quot;,    &quot;proximic&quot;,    &quot;changedetection&quot;,    &quot;arabot&quot;,    &quot;WeSEE:Search&quot;,    &quot;niki-bot&quot;,    &quot;CrystalSemanticsBot&quot;,    &quot;rogerbot&quot;,    &quot;360Spider&quot;,    &quot;psbot&quot;,    &quot;InterfaxScanBot&quot;,    &quot;CC Metadata Scaper&quot;,    &quot;g00g1e.net&quot;,    &quot;GrapeshotCrawler&quot;,    &quot;urlappendbot&quot;,    &quot;brainobot&quot;,    &quot;fr-crawler&quot;,    &quot;binlar&quot;,    &quot;SimpleCrawler&quot;,    &quot;Twitterbot&quot;,    &quot;cXensebot&quot;,    &quot;smtbot&quot;,    &quot;bnf.fr_bot&quot;,    &quot;A6-Indexer&quot;,    &quot;ADmantX&quot;,    &quot;Facebot&quot;,    &quot;OrangeBot/&quot;,    &quot;memorybot&quot;,    &quot;AdvBot&quot;,    &quot;MegaIndex&quot;,    &quot;SemanticScholarBot&quot;,    &quot;ltx71&quot;,    &quot;nerdybot&quot;,    &quot;xovibot&quot;,    &quot;BUbiNG&quot;,    &quot;Qwantify&quot;,    &quot;archive.org_bot&quot;,    &quot;Applebot&quot;,    &quot;TweetmemeBot&quot;,    &quot;crawler4j&quot;,    &quot;findxbot&quot;,    &quot;S[eE][mM]rushBot&quot;,    &quot;yoozBot&quot;,    &quot;lipperhey&quot;,    &quot;Y!J&quot;,    &quot;Domain Re-Animator Bot&quot;,    &quot;AddThis&quot;,    &quot;Screaming Frog SEO Spider&quot;,    &quot;MetaURI&quot;,    &quot;Scrapy&quot;,    &quot;Livelap[bB]ot&quot;,    &quot;OpenHoseBot&quot;,    &quot;CapsuleChecker&quot;,    &quot;collection@infegy.com&quot;,    &quot;IstellaBot&quot;,    &quot;DeuSu/&quot;,    &quot;betaBot&quot;,    &quot;Cliqzbot/&quot;,    &quot;MojeekBot/&quot;,    &quot;netEstate NE Crawler&quot;,    &quot;SafeSearch microdata crawler&quot;,    &quot;Gluten Free Crawler/&quot;,    &quot;Sonic&quot;,    &quot;Sysomos&quot;,    &quot;Trove&quot;,    &quot;deadlinkchecker&quot;,    &quot;Slack-ImgProxy&quot;,    &quot;Embedly&quot;,    &quot;RankActiveLinkBot&quot;,    &quot;iskanie&quot;,    &quot;SafeDNSBot&quot;,    &quot;SkypeUriPreview&quot;,    &quot;Veoozbot&quot;,    &quot;Slackbot&quot;,    &quot;redditbot&quot;,    &quot;datagnionbot&quot;,    &quot;Google-Adwords-Instant&quot;,    &quot;adbeat_bot&quot;,    &quot;WhatsApp&quot;,    &quot;contxbot&quot;,    &quot;pinterest.com/bot&quot;,    &quot;electricmonk&quot;,    &quot;GarlikCrawler&quot;,    &quot;BingPreview/&quot;,    &quot;vebidoobot&quot;,    &quot;FemtosearchBot&quot;,    &quot;Yahoo Link Preview&quot;,    &quot;MetaJobBot&quot;,    &quot;DomainStatsBot&quot;,    &quot;mindUpBot&quot;,    &quot;Daum/&quot;,    &quot;Jugendschutzprogramm-Crawler&quot;,    &quot;Xenu Link Sleuth&quot;,    &quot;Pcore-HTTP&quot;,    &quot;moatbot&quot;,    &quot;KosmioBot&quot;,    &quot;[pP]ingdom&quot;,    &quot;AppInsights&quot;,    &quot;PhantomJS&quot;,    &quot;Gowikibot&quot;,    &quot;PiplBot&quot;,    &quot;Discordbot&quot;,    &quot;TelegramBot&quot;,    &quot;Jetslide&quot;,    &quot;newsharecounts&quot;,    &quot;James BOT&quot;,    &quot;Bark[rR]owler&quot;,    &quot;TinEye&quot;,    &quot;SocialRankIOBot&quot;,    &quot;trendictionbot&quot;,    &quot;Ocarinabot&quot;,    &quot;epicbot&quot;,    &quot;Primalbot&quot;,    &quot;DuckDuckGo-Favicons-Bot&quot;,    &quot;GnowitNewsbot&quot;,    &quot;Leikibot&quot;,    &quot;LinkArchiver&quot;,    &quot;YaK/&quot;,    &quot;PaperLiBot&quot;,    &quot;Digg Deeper&quot;,    &quot;dcrawl&quot;,    &quot;Snacktory&quot;,    &quot;AndersPinkBot&quot;,    &quot;Fyrebot&quot;,    &quot;EveryoneSocialBot&quot;,    &quot;Mediatoolkitbot&quot;,    &quot;Luminator-robots&quot;,    &quot;ExtLinksBot&quot;,    &quot;SurveyBot&quot;,    &quot;NING/&quot;,    &quot;okhttp&quot;,    &quot;Nuzzel&quot;,    &quot;omgili&quot;,    &quot;PocketParser&quot;,    &quot;YisouSpider&quot;,    &quot;um-LN&quot;,    &quot;ToutiaoSpider&quot;,    &quot;MuckRack&quot;,    &quot;Jamie&#39;s Spider&quot;,    &quot;AHC/&quot;,    &quot;NetcraftSurveyAgent&quot;,    &quot;Laserlikebot&quot;,    &quot;^Apache-HttpClient&quot;,    &quot;AppEngine-Google&quot;,    &quot;Jetty&quot;,    &quot;Upflow&quot;,    &quot;Thinklab&quot;,    &quot;Traackr.com&quot;,    &quot;Twurly&quot;,    &quot;Mastodon&quot;,    &quot;http_get&quot;,    &quot;DnyzBot&quot;,    &quot;botify&quot;,    &quot;007ac9 Crawler&quot;,    &quot;BehloolBot&quot;,    &quot;BrandVerity&quot;,    &quot;check_http&quot;,    &quot;BDCbot&quot;,    &quot;ZumBot&quot;,    &quot;EZID&quot;,    &quot;ICC-Crawler&quot;,    &quot;ArchiveBot&quot;,    &quot;^LCC &quot;,    &quot;filterdb.iss.net/crawler&quot;,    &quot;BLP_bbot&quot;,    &quot;BomboraBot&quot;,    &quot;Buck/&quot;,    &quot;Companybook-Crawler&quot;,    &quot;Genieo&quot;,    &quot;magpie-crawler&quot;,    &quot;MeltwaterNews&quot;,    &quot;Moreover&quot;,    &quot;newspaper/&quot;,    &quot;ScoutJet&quot;,    &quot;(^| )sentry/&quot;,    &quot;StorygizeBot&quot;,    &quot;UptimeRobot&quot;,    &quot;OutclicksBot&quot;,    &quot;seoscanners&quot;,    &quot;Hatena&quot;,    &quot;Google Web Preview&quot;,    &quot;MauiBot&quot;,    &quot;AlphaBot&quot;,    &quot;SBL-BOT&quot;,    &quot;IAS crawler&quot;,    &quot;adscanner&quot;,    &quot;Netvibes&quot;,    &quot;acapbot&quot;,    &quot;Baidu-YunGuanCe&quot;,    &quot;bitlybot&quot;,    &quot;blogmuraBot&quot;,    &quot;Bot.AraTurka.com&quot;,    &quot;bot-pge.chlooe.com&quot;,    &quot;BoxcarBot&quot;,    &quot;BTWebClient&quot;,    &quot;ContextAd Bot&quot;,    &quot;Digincore bot&quot;,    &quot;Disqus&quot;,    &quot;Feedly&quot;,    &quot;Fetch/&quot;,    &quot;Fever&quot;,    &quot;Flamingo_SearchEngine&quot;,    &quot;FlipboardProxy&quot;,    &quot;g2reader-bot&quot;,    &quot;G2 Web Services&quot;,    &quot;imrbot&quot;,    &quot;K7MLWCBot&quot;,    &quot;Kemvibot&quot;,    &quot;Landau-Media-Spider&quot;,    &quot;linkapediabot&quot;,    &quot;vkShare&quot;,    &quot;Siteimprove.com&quot;,    &quot;BLEXBot/&quot;,    &quot;DareBoost&quot;,    &quot;ZuperlistBot/&quot;,    &quot;Miniflux/&quot;,    &quot;Feedspot&quot;,    &quot;Diffbot/&quot;,    &quot;SEOkicks&quot;,    &quot;tracemyfile&quot;,    &quot;Nimbostratus-Bot&quot;,    &quot;zgrab&quot;,    &quot;PR-CY.RU&quot;,    &quot;AdsTxtCrawler&quot;,    &quot;Datafeedwatch&quot;,    &quot;Zabbix&quot;,    &quot;TangibleeBot&quot;,    &quot;google-xrawler&quot;,    &quot;axios&quot;,    &quot;Amazon CloudFront&quot;,    &quot;Pulsepoint&quot;,    &quot;CloudFlare-AlwaysOnline&quot;,    &quot;Cloudflare-Healthchecks&quot;,    &quot;Cloudflare-Traffic-Manager&quot;,    &quot;CloudFlare-Prefetch&quot;,    &quot;Cloudflare-SSLDetector&quot;,    &quot;https://developers.cloudflare.com/security-center/&quot;,    &quot;Google-Structured-Data-Testing-Tool&quot;,    &quot;WordupInfoSearch&quot;,    &quot;WebDataStats&quot;,    &quot;HttpUrlConnection&quot;,    &quot;ZoomBot&quot;,    &quot;VelenPublicWebCrawler&quot;,    &quot;MoodleBot&quot;,    &quot;jpg-newsbot&quot;,    &quot;outbrain&quot;,    &quot;W3C_Validator&quot;,    &quot;Validator.nu&quot;,    &quot;W3C-checklink&quot;,    &quot;W3C-mobileOK&quot;,    &quot;W3C_I18n-Checker&quot;,    &quot;FeedValidator&quot;,    &quot;W3C_CSS_Validator&quot;,    &quot;W3C_Unicorn&quot;,    &quot;Google-PhysicalWeb&quot;,    &quot;Blackboard&quot;,    &quot;ICBot/&quot;,    &quot;BazQux&quot;,    &quot;Twingly&quot;,    &quot;Rivva&quot;,    &quot;Experibot&quot;,    &quot;awesomecrawler&quot;,    &quot;Dataprovider.com&quot;,    &quot;GroupHigh/&quot;,    &quot;theoldreader.com&quot;,    &quot;AnyEvent&quot;,    &quot;Uptimebot.org&quot;,    &quot;Nmap Scripting Engine&quot;,    &quot;2ip.ru&quot;,    &quot;Clickagy&quot;,    &quot;Caliperbot&quot;,    &quot;MBCrawler&quot;,    &quot;online-webceo-bot&quot;,    &quot;B2B Bot&quot;,    &quot;AddSearchBot&quot;,    &quot;Google Favicon&quot;,    &quot;HubSpot&quot;,    &quot;Chrome-Lighthouse&quot;,    &quot;HeadlessChrome&quot;,    &quot;CheckMarkNetwork/&quot;,    &quot;www.uptime.com&quot;,    &quot;Streamline3Bot/&quot;,    &quot;serpstatbot/&quot;,    &quot;MixnodeCache/&quot;,    &quot;^curl&quot;,    &quot;SimpleScraper&quot;,    &quot;RSSingBot&quot;,    &quot;Jooblebot&quot;,    &quot;fedoraplanet&quot;,    &quot;Friendica&quot;,    &quot;NextCloud&quot;,    &quot;Tiny Tiny RSS&quot;,    &quot;RegionStuttgartBot&quot;,    &quot;Bytespider&quot;,    &quot;Datanyze&quot;,    &quot;Google-Site-Verification&quot;,    &quot;TrendsmapResolver&quot;,    &quot;tweetedtimes&quot;,    &quot;NTENTbot&quot;,    &quot;Gwene&quot;,    &quot;SimplePie&quot;,    &quot;SearchAtlas&quot;,    &quot;Superfeedr&quot;,    &quot;feedbot&quot;,    &quot;UT-Dorkbot&quot;,    &quot;Amazonbot&quot;,    &quot;SerendeputyBot&quot;,    &quot;Eyeotabot&quot;,    &quot;officestorebot&quot;,    &quot;Neticle Crawler&quot;,    &quot;SurdotlyBot&quot;,    &quot;LinkisBot&quot;,    &quot;AwarioSmartBot&quot;,    &quot;AwarioRssBot&quot;,    &quot;RyteBot&quot;,    &quot;FreeWebMonitoring SiteChecker&quot;,    &quot;AspiegelBot&quot;,    &quot;NAVER Blog Rssbot&quot;,    &quot;zenback bot&quot;,    &quot;SentiBot&quot;,    &quot;Domains Project/&quot;,    &quot;Pandalytics&quot;,    &quot;VKRobot&quot;,    &quot;bidswitchbot&quot;,    &quot;tigerbot&quot;,    &quot;NIXStatsbot&quot;,    &quot;Atom Feed Robot&quot;,    &quot;[Cc]urebot&quot;,    &quot;PagePeeker/&quot;,    &quot;Vigil/&quot;,    &quot;rssbot/&quot;,    &quot;startmebot/&quot;,    &quot;JobboerseBot&quot;,    &quot;seewithkids&quot;,    &quot;NINJA bot&quot;,    &quot;Cutbot&quot;,    &quot;BublupBot&quot;,    &quot;BrandONbot&quot;,    &quot;RidderBot&quot;,    &quot;Taboolabot&quot;,    &quot;Dubbotbot&quot;,    &quot;FindITAnswersbot&quot;,    &quot;infoobot&quot;,    &quot;Refindbot&quot;,    &quot;BlogTraffic/d.d\\+ Feed-Fetcher&quot;,    &quot;SeobilityBot&quot;,    &quot;Cincraw&quot;,    &quot;Dragonbot&quot;,    &quot;VoluumDSP-content-bot&quot;,    &quot;FreshRSS&quot;,    &quot;BitBot&quot;,    &quot;^PHP-Curl-Class&quot;,    &quot;Google-Certificates-Bridge&quot;,    &quot;centurybot&quot;,    &quot;Viber&quot;,    &quot;e.ventures Investment Crawler&quot;,    &quot;evc-batch&quot;,    &quot;PetalBot&quot;,    &quot;virustotal&quot;,    &quot;(^| )PTST/&quot;,    &quot;minicrawler&quot;,    &quot;Cookiebot&quot;,    &quot;trovitBot&quot;,    &quot;seostar.co&quot;,    &quot;IonCrawl&quot;,    &quot;Uptime-Kuma&quot;,    &quot;Seekport&quot;,    &quot;FreshpingBot&quot;,    &quot;Feedbin&quot;,    &quot;CriteoBot&quot;,    &quot;Snap URL Preview Service&quot;,    &quot;Better Uptime Bot&quot;,    &quot;RuxitSynthetic&quot;,    &quot;Google-Read-Aloud&quot;,    &quot;Valve/Steam&quot;,    &quot;OdklBot/&quot;,    &quot;GPTBot&quot;,    &quot;ChatGPT-User&quot;,    &quot;OAI-SearchBot&quot;,    &quot;YandexRenderResourcesBot/&quot;,    &quot;LightspeedSystemsCrawler&quot;,    &quot;ev-crawler/&quot;,    &quot;BitSightBot/&quot;,    &quot;woorankreview/&quot;,    &quot;Google-Safety&quot;,    &quot;AwarioBot&quot;,    &quot;DataForSeoBot&quot;,    &quot;Linespider&quot;,    &quot;WellKnownBot&quot;,    &quot;A Patent Crawler&quot;,    &quot;StractBot&quot;,    &quot;search.marginalia.nu&quot;,    &quot;YouBot&quot;,    &quot;Nicecrawler&quot;,    &quot;Neevabot&quot;,    &quot;BrightEdge Crawler&quot;,    &quot;SiteCheckerBotCrawler&quot;,    &quot;TombaPublicWebCrawler&quot;,    &quot;CrawlyProjectCrawler&quot;,    &quot;KomodiaBot&quot;,    &quot;KStandBot&quot;,    &quot;CISPA Webcrawler&quot;,    &quot;MTRobot&quot;,    &quot;hyscore.io&quot;,    &quot;AlexandriaOrgBot&quot;,    &quot;2ip bot&quot;,    &quot;Yellowbrandprotectionbot&quot;,    &quot;SEOlizer&quot;,    &quot;vuhuvBot&quot;,    &quot;INETDEX-BOT&quot;,    &quot;Synapse&quot;,    &quot;t3versionsBot&quot;,    &quot;deepnoc&quot;,    &quot;Cocolyzebot&quot;,    &quot;hypestat&quot;,    &quot;ReverseEngineeringBot&quot;,    &quot;sempi.tech&quot;,    &quot;Iframely&quot;,    &quot;MetaInspector&quot;,    &quot;node-fetch&quot;,    &quot;l9explore&quot;,    &quot;python-opengraph&quot;,    &quot;OpenGraphCheck&quot;,    &quot;developers.google.com/\\+/web/snippet&quot;,    &quot;SenutoBot&quot;,    &quot;MaCoCu&quot;,    &quot;NewsBlur&quot;,    &quot;inoreader&quot;,    &quot;NetSystemsResearch&quot;,    &quot;PageThing&quot;,    &quot;WordPress/&quot;,    &quot;PhxBot&quot;,    &quot;ImagesiftBot&quot;,    &quot;Expanse&quot;,    &quot;InternetMeasurement&quot;,    &quot;^BW/&quot;,    &quot;GeedoBot&quot;,    &quot;Audisto Crawler&quot;,    &quot;PerplexityBot/&quot;,    &quot;[cC]laude[bB]ot&quot;,    &quot;Monsidobot&quot;,    &quot;GroupMeBot&quot;,    &quot;Vercelbot&quot;,    &quot;vercel-screenshot&quot;,    &quot;facebookcatalog/&quot;,    &quot;meta-externalads/&quot;,    &quot;meta-externalagent/&quot;,    &quot;meta-externalfetcher/&quot;,    &quot;AcademicBotRTU&quot;,    &quot;KeybaseBot&quot;,    &quot;Lemmy&quot;,    &quot;CookieHubScan&quot;,    &quot;Hydrozen.io&quot;,    &quot;HTTP Banner Detection&quot;,    &quot;SummalyBot&quot;,    &quot;MicrosoftPreview/&quot;,    &quot;GeedoProductSearch&quot;,    &quot;TikTokSpider&quot;,    &quot;OnCrawl/&quot;,    &quot;sindresorhus/got&quot;,    &quot;CensysInspect/&quot;,    &quot;SBIntuitionsBot/&quot;,    &quot;sitebulb&quot;,    &quot;YextBot/&quot;,    &quot;DatadogSynthetics&quot;,    &quot;Google-Ads-Conversions&quot;        ];<br>    public static readonly Regex BotRegex = new Regex(<br>        string.Join(&quot;|&quot;, Patterns),<br>        RegexOptions.Compiled | RegexOptions.IgnoreCase);<br>}</pre><pre>var userAgent = _httpContextAccessor?.HttpContext?.Request?.Headers[&quot;User-Agent&quot;].ToString() ?? &quot;&quot;;<br>bool isBot = BotPatterns.BotRegex.IsMatch(userAgent);</pre><p>If the request is from Bot, then do not load the Google analytics script which will prevent logging data in Google analytics</p><pre> @if (!Model.IsBot)<br> {<br>     &lt;!-- Google Tag Manager --&gt;<br>     &lt;script&gt;<br>         console.log(&quot;GTM Script loaded&quot;);<br>         (function (w, d, s, l, i) {<br>             w[l] = w[l] || [];<br>             w[l].push({<br>                 &#39;gtm.start&#39;: new Date().getTime(),<br>                 event: &#39;gtm.js&#39;<br>             });<br>             var f = d.getElementsByTagName(s)[0],<br>                 j = d.createElement(s),<br>                 dl = l != &#39;dataLayer&#39; ? &#39;&amp;l=&#39; + l : &#39;&#39;;<br>             j.async = true;<br>             j.src = &#39;https://www.googletagmanager.com/gtm.js?id=&#39; + i + dl;<br>             f.parentNode.insertBefore(j, f);<br>         })(window, document, &#39;script&#39;, &#39;dataLayer&#39;, GAAccountID);<br>     &lt;/script&gt;<br> }</pre><h3><strong>The Real Challenge: Maintaining the Bot Patterns</strong></h3><p>Why this was a challenge</p><ul><li>Bot constantly evolves</li><li>Hardcoding a static list is unreliable</li><li>Manual maintenance is not scalable</li><li>Downloading it every time at runtime introduces latency</li></ul><p><strong>Solution:</strong></p><p>Instead of maintaining our own list of bot patterns, we rely on the widely used and frequently updated open-source dataset <strong>“crawler-user-agents.json”</strong> available on GitHub. This ensures we’re always aligned with the latest known crawlers without reinventing the wheel.</p><p>To integrate this into our application, we introduced a PowerShell-based build step:</p><ol><li>During the build process, a PowerShell script is executed.</li><li>The script fetches and parses the latest bot patterns from the JSON dataset.</li><li>It then generates a C# file (BotPatterns.cs - Refer above section to see the generated file) containing:</li></ol><ul><li>A static list of bot user-agent patterns</li><li>Precompiled regular expressions for efficient matching.</li></ul><p>This generated file becomes part of the application at compile time, meaning the bot detection logic is baked directly into the code before the application even starts.</p><p>This solution ensures</p><ul><li>Always up-to-date detection of Bot patterns</li><li>Faster request handling</li><li>No extra latency for users</li><li>Better application performance</li></ul><pre>try<br>{<br># Step 1: Download the crawler user agents JSON<br>$sourceUrl = &quot;https://raw.githubusercontent.com/monperrus/crawler-user-agents/master/crawler-user-agents.json&quot;<br>$response = Invoke-WebRequest -Uri $sourceUrl<br>$json = $response.Content | ConvertFrom-Json<br><br># Step 2: Extract &quot;pattern&quot; strings<br>$patterns = $json | ForEach-Object { $_.pattern }<br><br># Escape + literally<br>$escapedPatterns = $patterns | ForEach-Object {<br>    $_ -replace &#39;\\&#39;, &#39;&#39; -replace &#39;&quot;&#39;, &#39;\&quot;&#39; -replace &#39;\+&#39;, &#39;\\+&#39;<br>}<br><br># Step 4: Generate C# code<br>$code = @&quot;<br>    using System.Text.RegularExpressions;<br>namespace VillaPlus.Website.BotDetection<br>{<br>    // Auto-generated at build time<br>    public static class BotPatterns<br>    {<br>        public static readonly string[] Patterns  = [<br>&quot;@<br><br>foreach ($pattern in $escapedPatterns) {<br>    $code += &quot;    `&quot;$pattern`&quot;,&quot;<br>}<br>$code = $code.TrimEnd(&#39;,&#39;)<br>$code += @&quot;<br>        ];<br>        public static readonly Regex BotRegex = new Regex(<br>            string.Join(&quot;|&quot;, Patterns),<br>            RegexOptions.Compiled | RegexOptions.IgnoreCase);<br>    }<br>}<br>&quot;@<br><br># Step 5: Write the file to your project folder (adjust path as needed)<br>    $outputPath = &quot;BotPatterns/BotPatterns.cs&quot;<br>    $dir = Split-Path $outputPath<br>    if (-not (Test-Path $dir)) {<br>        New-Item -ItemType Directory -Path $dir -Force | Out-Null<br>    }<br>    if (-not (Test-Path $outputPath) -or (Get-Content $outputPath -Raw) -ne $code) {<br>        Set-Content -Path $outputPath -Value $code -Encoding UTF8<br>        Write-Host &quot;BotPatterns.cs updated at: $outputPath&quot;<br>    } else {<br>        Write-Host &quot;BotPatterns.cs unchanged&quot;<br>    }<br>}<br>catch {<br>    exit 1<br>}</pre><h3><strong>What we achieved</strong></h3><p>· Minimized distortion to a level where decisions remain reliable.</p><p>· Bounce rate anomalies were reduced</p><p>· Strengthening the integrity of our reporting by reducing the noise substantially</p><p>· Created a framework that can adapt as new patterns emerge.</p><p>Even after implementing exclusions, we understand that not all non-human traffic can be eliminated. Advanced scrapers may still appear as legitimate users in Google analytics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3924aa4c35c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/filtering-out-bot-traffic-from-analytics-3924aa4c35c1">Filtering out Bot traffic from Analytics</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our First Time Using an AI Model in Production]]></title>
            <link>https://medium.com/villa-plus-engineering/our-first-time-using-an-ai-model-in-production-55e4ddae82fd?source=rss----bc02d31bd1e4---4</link>
            <guid isPermaLink="false">https://medium.com/p/55e4ddae82fd</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[azure-foundry]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azureopenai]]></category>
            <dc:creator><![CDATA[Oliver Jones]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 08:43:05 GMT</pubDate>
            <atom:updated>2026-02-16T08:43:04.471Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Last year, we took the plunge and integrated an AI chat model directly into our production code for the first time. The goal was simple, automate professional responses to customer reviews from platforms like Trustpilot and Airbnb.</p><p>This post outlines what we built, how we integrated the AI, key challenges we faced, and what we learned with practical insights for developers considering a similar path.</p><p><strong>What We Built</strong></p><p>We created a tool that generates suggested responses to customer reviews:</p><ul><li>Multiple review sources feed a review event into our system.</li><li>An Azure Function App receives the event, analyses the text and rating, then generates a reply and identifies topics discussed using an AI model.</li><li>The reply is saved to our database.</li><li>A web UI dashboard displays the review and suggested response for quick human review before manual posting.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*hWreT2a32d1jNnfzcPJAQg.png" /><figcaption>Simplified overview of system.</figcaption></figure><p>This setup reduced manual work while keeping quality control in human hands.</p><p><strong>How We Integrated AI</strong></p><p>We chose to integrate OpenAI models hosted on Azure OpenAI, mainly because Azure Foundry was not available at the time this feature was developed. This fits our Azure-first infrastructure and provides enterprise-friendly authentication, security, and billing options. In the future we plan on migrating over to Foundry.</p><p><strong>Key steps in our integration:</strong></p><ul><li>Provision an Azure OpenAI / Foundry resource and deploy a chat model (e.g., GPT-4.1-mini) using the Azure Portal / BICEP templates.</li><li>Authenticate securely using Managed Identity for our Azure Function App, avoiding long-lived API keys.</li><li>Interact with the model using the Azure.AI.OpenAI NuGet package.</li></ul><p>Here’s a simplified example of how we generated a completion:</p><blockquote>var client = new ChatClient(endpoint, credential);</blockquote><blockquote>var response = await client.GetChatCompletionsAsync(</blockquote><blockquote>deploymentName,</blockquote><blockquote>new ChatMessage[]</blockquote><blockquote>{</blockquote><blockquote>new SystemMessage(systemPrompt),</blockquote><blockquote>new UserMessage(reviewText)</blockquote><blockquote>});</blockquote><blockquote>var reviewResponse = response.Choices[0].Message.Content;</blockquote><p><strong>Prompt Design &amp; Data Validation</strong></p><p>The biggest challenge wasn’t writing the code it was getting the model to return consistent results.</p><p>Early responses varied in tone, structure, and length. To fix this we focused on:</p><ol><li><strong>Prompt clarity:</strong> Clearly defined instructions including tone, constraints, and examples. (We found the model often ignored guidelines went off script, it took multiple testing to get consistent results).</li><li><strong>Structured output:</strong> We enforced JSON or schema-based output using the model’s structured output support so we could reliably parse and validate responses.</li><li><strong>Validation:</strong> All model outputs were validated before being saved or displayed.</li></ol><p><strong>Lessons from prompt design:</strong></p><ul><li>Be explicit about output requirements (e.g., exact JSON fields).</li><li>Provide examples for both good and bad responses.</li><li>Avoid overly long or mixed instructions.</li></ul><p>We relied heavily on Azure Chat Playground when developing the system instructions used by the model. This helped us quickly iterate though versions and refine out prompt.</p><p><strong>Cost Management</strong></p><p>AI costs scale with prompt size and model choice. We found it critical to:</p><ul><li>Keep prompts minimal but precise</li><li>Split tasks when possible (e.g., topic analysis from response generation).</li><li>Avoid unnecessarily long context history unless needed.</li></ul><p>Mixing models for different subtasks can further optimise quality vs cost if your platform supports it.</p><p><strong>What We’d Improve</strong></p><p>This project works well, but if we built it again we would:</p><ul><li>Introduce more advanced structured prompts with schema enforcement for tighter control</li><li>Improve validation on model completion, making to check any structured response e.g. JSON.</li><li>Introduce model switching depending on the task to reduce on costs.</li><li>Introduce POML, Microsoft’s prompting language which is designed to bring more structure and organisation to prompting LLM’s</li></ul><p><strong>Final Thoughts</strong></p><p>The technical hurdles especially around prompt design and consistent output were far more complex than the actual API integration. But with careful prompt planning and solid testing, we ended up with a reliable and useful feature that delivers business value.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e4ddae82fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/our-first-time-using-an-ai-model-in-production-55e4ddae82fd">Our First Time Using an AI Model in Production</a> was originally published in <a href="https://medium.com/villa-plus-engineering">Villa Plus Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>