<?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[Stories by Yuliia Merenko on Medium]]></title>
        <description><![CDATA[Stories by Yuliia Merenko on Medium]]></description>
        <link>https://medium.com/@yuliia_86402?source=rss-06d263b73d0b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iNgpEWAsE7fdEAJAbG5kHA.jpeg</url>
            <title>Stories by Yuliia Merenko on Medium</title>
            <link>https://medium.com/@yuliia_86402?source=rss-06d263b73d0b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 17:04:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yuliia_86402/feed" 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-06d263b73d0b------2</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:11 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[Setting Up SharePoint Integration Using PnP Core SDK: A Step-by-Step Guide]]></title>
            <link>https://medium.com/villa-plus-engineering/setting-up-sharepoint-integration-using-pnp-core-sdk-a-step-by-step-guide-c5e74f283bd9?source=rss-06d263b73d0b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5e74f283bd9</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[entra-id]]></category>
            <category><![CDATA[sharepoint-integration]]></category>
            <category><![CDATA[sharepoint]]></category>
            <dc:creator><![CDATA[Yuliia Merenko]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 11:02:16 GMT</pubDate>
            <atom:updated>2024-11-26T11:02:16.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="PnP Core SDK" src="https://cdn-images-1.medium.com/max/802/0*GhWIgA5ZiaHxNyBV.png" /><figcaption>PnP Core SDK</figcaption></figure><p>Integrating SharePoint with your application can be a critical part of automating workflows, managing documents, and providing seamless access to collaboration spaces. With the power of the <a href="https://pnp.github.io/pnpcore/">PnP Core SDK</a>, SharePoint integration becomes more manageable and efficient. This guide walks you through the process of setting up SharePoint integration by configuring certificates, permissions, and the PnP Core SDK for smooth operations.</p><p><strong>Prerequisites</strong></p><p>Before diving into the configuration, there are some prerequisites that need to be met:</p><ul><li><a href="https://pnp.github.io/powershell/index.html"><strong>PowerShell PnP Module</strong></a>: This allows you to interact with SharePoint and Microsoft Entra ID through PowerShell.</li></ul><pre>Install-Module -Name PnP.PowerShell -AllowClobber</pre><ul><li><strong>PowerShell Version 7</strong>: Ensure you are using PowerShell 7 or higher. To check your current version, use:</li></ul><pre>$PSVersionTable.PSVersion</pre><p>Once these are set up, you’ll be ready to configure the SharePoint site, app registrations, and permissions.</p><p><strong>Step 1: Create a New SharePoint Site</strong></p><p>Start by creating a new site in SharePoint to house your documents or other content. This can be done through the SharePoint Admin Centre or via the SharePoint REST API, depending on your requirements.</p><p><strong>Step 2: Create a Certificate in Azure Key Vault</strong></p><p>Security is key when integrating with SharePoint. Creating a certificate in Azure Key Vault ensures that your authentication credentials are stored securely.</p><p>1. Create a <strong>Key Vault</strong> in the Azure portal.</p><p>2. Generate or import a certificate into the Key Vault. This certificate will be used to authenticate your app against SharePoint.</p><p><strong>Step 3: Import Certificate in App Registration &amp; App Service</strong></p><p>The certificate you created in Key Vault needs to be imported into your app registration and app service.</p><p>1. Navigate to your <strong>App Registration</strong> in Microsoft Entra ID.</p><p>2. Under <strong>Certificates &amp; Secrets</strong>, import the certificate directly from Azure Key Vault. Ensure that the <strong>App Registration</strong> uses this certificate for authentication.</p><p>3. Navigate to your <strong>App Service</strong> in Azure Portal.</p><p>4. Under <strong>Certificates -&gt; Bring your own certificates (.pfx)</strong>, import the certificate from Azure Key Vault.</p><p><strong>Step 4: Set Environment Variables for the Application</strong></p><p>Next, set the following environment variables for your application:</p><ul><li>WEBSITE_LOAD_CERTIFICATES should be set to * (to allow the loading of certificates).</li><li>SharePoint__CertificateThumbprint should be set to the thumbprint of the certificate created in Azure Key Vault.</li></ul><p><strong>Step 5: Set Up App Registration for Admin Access</strong></p><p>Create a separate App Registration for admin access to SharePoint. Assign the appropriate <strong>API permissions</strong> such as <strong>Sites.FullControl.All</strong> for managing SharePoint sites. Then grant admin consent for the selected permissions.</p><figure><img alt="API Permissions for Admin App Registration" src="https://cdn-images-1.medium.com/max/323/1*fmXuQj6SrjL2s8ey4Ki2iQ.png" /><figcaption>API Permissions for Admin App Registration</figcaption></figure><p><strong>Step 6: Set SharePoint Permissions for the App Registration</strong></p><p>Assign <strong>Sites.Selected</strong> permissions for the app registration to interact with specific SharePoint sites. This limits the application to perform actions such as reading, writing, and managing documents to the specific SharePoint site.</p><figure><img alt="API Permissions for App Registration which interacts with SharePoint" src="https://cdn-images-1.medium.com/max/321/1*9a48Pkc06S3hCBrLv8afWw.png" /><figcaption>API Permissions for App Registration which interacts with SharePoint</figcaption></figure><p>To assign <strong>Write</strong> permissions, use a script in PowerShell, as shown below:</p><pre>$adminAppClientId = &quot;&lt;App Id from Step 5&gt;&quot;<br>$sharePointAppClientId = &quot;&lt;App Id from Step 6&gt;&quot;<br>$sharePointAppName = &quot;&lt;App Name from Step 6&gt;&quot;<br>$siteUrl = &quot;https://&lt;tenantName&gt;.sharepoint.com/sites/&lt;yourSite&gt;&quot;<br>Connect-PnPOnline https://&lt;tenantName&gt;.sharepoint.com -Interactive -ClientId $adminAppClientId<br>Grant-PnPAzureADAppSitePermission -AppId $sharePointAppClientId -DisplayName $sharePointAppName -Permissions Write -Site $siteUrl</pre><p>After running the script, the output should show the permissions granted to the app registration:</p><pre>Id : &lt;permission id&gt;<br>Roles : {write}<br>Apps : {&lt;sharePointAppName&gt;, &lt;sharePointAppClientId&gt;}</pre><p><strong>Step 7: Install PnP Core and Configure Authentication</strong></p><p>For the application to interact with SharePoint, you’ll need to install the <a href="https://www.nuget.org/packages/PnP.Core/1.14.0"><strong>PnP Core</strong></a> and <a href="https://www.nuget.org/packages/PnP.Core.Auth/1.14.0"><strong>PnP Core Auth</strong></a> packages.</p><pre>Install-Package PnP.Core<br>Install-Package PnP.Core.Auth</pre><p>Next, configure <strong>PnP Core services</strong> in the <em>Startup.cs</em> file to authenticate the application using the certificate.</p><p><strong>For Windows:</strong></p><pre>var authProvider = new X509CertificateAuthenticationProvider(<br>    clientId,<br>    tenantId,<br>    StoreName.My,<br>    StoreLocation.CurrentUser,<br>    sharepointOptions.CertificateThumbprint);</pre><p><strong>For Linux:</strong></p><pre>var sharepointCertificate = new X509Certificate2($&quot;{sharepointOptions.CertificatePath}{sharepointOptions.CertificateThumbprint}{sharepointOptions.CertificateExtension}&quot;);<br>var authProvider = new X509CertificateAuthenticationProvider(<br>    clientId,<br>    tenantId,<br>    sharepointCertificate);</pre><p><strong>Step 8: Add PnP Core Services to the Application</strong></p><p>Now, add the PnP Core services to your application, ensuring the authentication provider is set up properly:</p><pre>services.AddPnPCore(options =&gt;<br>{<br>    options.DefaultAuthenticationProvider = authProvider;<br>    options.Sites.Add(sharepointOptions.SiteConfigName, new PnPCoreSiteOptions<br>    {<br>        SiteUrl = sharepointOptions.SiteUrl,<br>        AuthenticationProvider = authProvider<br>    });<br>});</pre><p><strong>Step 9: Configure Application Settings in Configuration Files</strong></p><p>In your <em>appsettings.json</em>, set up the configuration details for SharePoint:</p><pre>&quot;SharePoint&quot;: {<br>  &quot;SiteUrl&quot;: &quot;https://&lt;tenantName&gt;.sharepoint.com/sites/&lt;yourSite&gt;&quot;,<br>  &quot;SiteConfigName&quot;: &quot;&lt;yourSite&gt;&quot;,<br>  &quot;CredentialConfigName&quot;: &quot;Certificate&quot;,<br>  &quot;CertificateThumbprint&quot;: &quot;&quot;,<br>  &quot;CertificateExtension&quot;: &quot;&quot;,<br>  &quot;CertificatePath&quot;: &quot;/var/ssl/private/&quot;,<br>  &quot;DocumentsFolderName&quot;: &quot;Shared Documents&quot;<br>}</pre><p>NOTE:</p><ul><li><em>CertificateExtension</em> is the file extension for the certificate, e.g. “&lt;<em>CertificateThumbprint</em>&gt;.p12”.</li><li><em>CertificateExtension</em> and <em>CertificatePath</em> need to be specified for Linux apps only. Windows uses <em>StoreName.My</em> and <em>StoreLocation.CurrentUser</em> to get certificates from the store.</li><li><em>SiteConfigName</em> and <em>CredentialConfigName</em> can be set to any value.</li><li><em>DocumentsFolderName</em> is the main SharePoint site folder, set to “Shared Documents” by default when the site is created.</li></ul><p><strong>Step 10: Upload a File to SharePoint</strong></p><p>Finally, use the <em>IPnPContextFactory</em> to interact with SharePoint, such as upload a file. Here’s an example method to upload a file to a SharePoint site:</p><pre>public async Task Upload(IFormFile file)<br>{<br>    try<br>    {<br>        using var context = await pnpContextFactory.CreateAsync(sharePointConfiguration.SiteConfigName);<br>        var documentsFolder = await context.Web.Folders.Where(f =&gt; f.Name == sharePointConfiguration.DocumentsFolderName).FirstOrDefaultAsync();<br>        var addedFile = await documentsFolder.Files.AddAsync(file.FileName, file.OpenReadStream(), true);<br>    }<br>    catch (Exception ex)<br>    {<br>        logger.LogError(ex, ex.Message);<br>    }<br>}</pre><p><strong>Step 11: Running Locally</strong></p><p>To run this setup locally, download the certificate in <strong>PFX/PEM</strong> format and import it into your system’s certificate store. On Windows, go to <strong>Manage user certificates</strong> -&gt; <strong>Personal</strong> -&gt; <strong>Certificates</strong>, and import the certificate.</p><p><strong>Conclusion</strong></p><p>By following these steps, you can seamlessly integrate SharePoint with your application using the PnP Core SDK. This process covers certificate setup, permission configuration, and PnP Core SDK integration, enabling you to manage SharePoint documents and permissions with ease. As always, make sure you have the necessary administrative rights to execute these tasks and collaborate with your team for any permissions needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5e74f283bd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/villa-plus-engineering/setting-up-sharepoint-integration-using-pnp-core-sdk-a-step-by-step-guide-c5e74f283bd9">Setting Up SharePoint Integration Using PnP Core SDK: A Step-by-Step 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>
    </channel>
</rss>