<?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"><channel><title><![CDATA[by Jacob Møhl]]></title><description><![CDATA[Hello my name is Jacob Møhl a cloud solution architect with a passion for Azure, .Net, design patterns and a little Swift and iOS.]]></description><link>https://www.jacobmohl.dk</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1689003219997/5pdMup9Wp.png</url><title>by Jacob Møhl</title><link>https://www.jacobmohl.dk</link></image><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 15:18:10 GMT</lastBuildDate><atom:link href="https://www.jacobmohl.dk/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to add OData parameters to your ASP.Net Core API]]></title><description><![CDATA[Bridge the gap between Microsoft.AspNetCore.OData and Swashbuckle.AspNetCore]]></description><link>https://www.jacobmohl.dk/how-to-add-odata-parameters-to-your-aspnet-core-api</link><guid isPermaLink="true">https://www.jacobmohl.dk/how-to-add-odata-parameters-to-your-aspnet-core-api</guid><category><![CDATA[TIL]]></category><category><![CDATA[asp.net core]]></category><category><![CDATA[C#]]></category><dc:creator><![CDATA[Jacob Møhl]]></dc:creator><pubDate>Wed, 25 Aug 2021 19:41:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1629920393373/_srIVqn1g.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>My team and I have worked with the <a target="_blank" href="https://www.nuget.org/packages/Microsoft.AspNetCore.OData/">OData nuget package from Microsoft</a> to add some OData magic to a normal REST API based on ASP.Net Core 3.1 (that setup is a blog post for another day 😅).</p>
<p>But along the way we found, that there were no out-of-the box solution to get the OData parameters visible in our normal OpenApi spec (generated by  <a target="_blank" href="https://github.com/domaindrivendev/Swashbuckle.AspNetCore">Swashbuckle</a> ).</p>
<p>So today I learned (#TIL) that its quite easy to inject some custom properties into the OpenAPI model trough a IOperationFilter.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="a7eb2f3b508b61a2bd04ef0fe6d6e1de"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/jacobmohl/a7eb2f3b508b61a2bd04ef0fe6d6e1de" class="embed-card">https://gist.github.com/jacobmohl/a7eb2f3b508b61a2bd04ef0fe6d6e1de</a></div><p>To utilize the above code, you have to add the following to the AddSwaggerGen builder (in Startup.cs or similar).</p>
<pre><code>services.AddSwaggerGen(c =&gt;
{
<span class="hljs-meta">...</span>
    // Add support for OData-like REST endpoint with [EnableQuery]
    c.OperationFilter&lt;ODataOperationFilter&gt;();
<span class="hljs-meta">...</span>
});
</code></pre><p>This enables all the OData parameters on the API methods which have the [EnableQuery] attribute.</p>
]]></content:encoded></item><item><title><![CDATA[How to create custom cookies in HTTP Triggered Azure Functions]]></title><description><![CDATA[Today i learned how to create custom cookies in HTTP Triggered Azure Functions.]]></description><link>https://www.jacobmohl.dk/how-to-create-custom-cookies-in-http-triggered-azure-functions</link><guid isPermaLink="true">https://www.jacobmohl.dk/how-to-create-custom-cookies-in-http-triggered-azure-functions</guid><category><![CDATA[asp.net core]]></category><category><![CDATA[Azure]]></category><dc:creator><![CDATA[Jacob Møhl]]></dc:creator><pubDate>Thu, 16 Apr 2020 20:03:02 GMT</pubDate><content:encoded><![CDATA[<p>As I were creating the a feature for site, I needed to check if a visitor already has given kudos to an article before. An easy way to do that (in my mind) is to randomly generate a GUID and store that in the browser to somehow recognize the browser/visitor again.</p>
<p>But all articles, blogs and SO post on handling cookies in ASP.Net Core all focus on dependency inject the IHttpContextAccessor or use the <a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpresponse?view=aspnetcore-5.0">HttpResponse </a> property on the ASP.Net Core controller it self to gain access to the  <a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.iresponsecookies?view=aspnetcore-5.0">ResponseCookies</a> . None of these methods works out of the box in Azure Functions! 🥺</p>
<p>But after some time searching and a little rubber ducking I realized that the HttpContext (and therefore the HttpResponse and its cookies) where accessible trough the incoming HttpRequest in the HttpTrigger. So when you know, pretty easy. Se below example.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="cf90c5d38185eed3782cfe0b393f03c7"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/jacobmohl/cf90c5d38185eed3782cfe0b393f03c7" class="embed-card">https://gist.github.com/jacobmohl/cf90c5d38185eed3782cfe0b393f03c7</a></div><p>After that i ran into some troubles with CORS, SameSite and other security related stuff, because my blog is a static website calling a Azure Function on another domain (but that is another post 🤔).</p>
]]></content:encoded></item><item><title><![CDATA[How to use Project-to-Project references in nuget packages with .NET Core CLI SDK]]></title><description><![CDATA[Today i learned how to include a dependent project inside a nuget package build with .Net Core CLI command pack.]]></description><link>https://www.jacobmohl.dk/use-project-to-project-references-in-nuget</link><guid isPermaLink="true">https://www.jacobmohl.dk/use-project-to-project-references-in-nuget</guid><category><![CDATA[TIL]]></category><category><![CDATA[asp.net core]]></category><category><![CDATA[C#]]></category><dc:creator><![CDATA[Jacob Møhl]]></dc:creator><pubDate>Sun, 15 Sep 2019 22:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Out of the box the dotnet pack command (from the .Net Core CLI) treat every project in the Visual Studio solution as its own Nuget package.</p>
<blockquote>
<p>Project-to-project references aren’t packaged inside the project. Currently, you must have a package per project if you have project-to-project dependencies. -  <a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-pack">.NET Core CLI Docs</a> </p>
</blockquote>
<p>Today i learned that if you add PrivateAssets="all" to the ProjectReferece in the .csproj file, these project will be included in the Nuget package, instead of marked as a dependency.</p>
<div class="gist-block embed-wrapper" data-gist-show-loading="false" data-id="483f4383607b0cab20c1b77abf52d604"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a href="https://gist.github.com/jacobmohl/483f4383607b0cab20c1b77abf52d604" class="embed-card">https://gist.github.com/jacobmohl/483f4383607b0cab20c1b77abf52d604</a></div><p>This only works for .NET Core or .NET Standard build with the .NET Core CLI and not .Net Framework build with MSBuild.</p>
]]></content:encoded></item><item><title><![CDATA[Why App Service instances can have wrong names in Application Insights]]></title><description><![CDATA[Do you sometimes sense that your app service has the wrong name in Application Insights?]]></description><link>https://www.jacobmohl.dk/why-app-service-instances-can-have-wrong-names-in-application-insights</link><guid isPermaLink="true">https://www.jacobmohl.dk/why-app-service-instances-can-have-wrong-names-in-application-insights</guid><category><![CDATA[Azure]]></category><dc:creator><![CDATA[Jacob Møhl]]></dc:creator><pubDate>Sun, 11 Aug 2019 22:00:00 GMT</pubDate><content:encoded><![CDATA[<p>Some of you are properly using the very cool feature on Azure App Services called “ <a target="_blank" href="https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots">Deployment slots</a> ” which lets you swap different instance in and out of your production website 🚀. Hopefully you are also using Application Insights to gather telemetry from your app.</p>
<p>But you might not have found out that the name or your website instance doesn't get swap when you move between the different slots. This means that if you are swapping ex. site.azurewebsites.net with site-dev.azurewebsites.net your "production" web app is actually still named site-dev.azurewebsites.net in your telemetry.</p>
<p>This bug took me and my team a while to figure out and we ended up making a request to Azure support to file a case. The reason for the bug is, that behind the scenes there is some kind of IIS website with a instance/role name. That name is not changed during a swap, because a role name change requires a restart, which will result in a cold start and defeat the purpose of the swap feature.</p>
<p>A nasty little learning from the real world 🤔</p>
]]></content:encoded></item></channel></rss>