<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jonas Samuelsson</title>
    <description>The latest articles on DEV Community by Jonas Samuelsson (@jonassamuelsson).</description>
    <link>https://dev.to/jonassamuelsson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F312941%2F5e3f4b0a-546c-4383-bda6-78d0ed452bee.jpg</url>
      <title>DEV Community: Jonas Samuelsson</title>
      <link>https://dev.to/jonassamuelsson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jonassamuelsson"/>
    <language>en</language>
    <item>
      <title>git rebase on pull</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Wed, 06 Nov 2024 08:21:03 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/git-rebase-on-pull-357i</link>
      <guid>https://dev.to/jonassamuelsson/git-rebase-on-pull-357i</guid>
      <description>&lt;p&gt;One way of getting a more linear history in git is to do rebase on pull.&lt;br&gt;
Run &lt;code&gt;git config --global pull.rebase true&lt;/code&gt; to set this globally.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Azure Data Studio account cache</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Tue, 10 Sep 2024 13:35:07 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/azure-data-studio-account-cache-4mpe</link>
      <guid>https://dev.to/jonassamuelsson/azure-data-studio-account-cache-4mpe</guid>
      <description>&lt;p&gt;I prefer using Azure Data Studio when I need to interact with SQL Server databases.&lt;br&gt;
Each time I want to connect to our production databases I need to elevate using Privileged Identity Management.&lt;br&gt;
Azure Data Studio caches my token but isn't smart enough to handle when the token has expired, instead I get this modal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5ik2mmgao6i59rlzwge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5ik2mmgao6i59rlzwge.png" alt="Image description" width="640" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The solution to this is to close Azure Data Studio and then delete the files located in &lt;code&gt;%userprofile%\AppData\Roaming\azuredatastudio\Azure Accounts&lt;/code&gt;, either manually or by using this powershell script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Get-ChildItem&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nv"&gt;$&lt;/span&gt;&lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;userprofile&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;\AppData\Roaming\azuredatastudio\Azure Accounts"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Remove-Item&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>kusto trendlines</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Fri, 02 Feb 2024 06:45:49 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/kusto-trendlines-5hl2</link>
      <guid>https://dev.to/jonassamuelsson/kusto-trendlines-5hl2</guid>
      <description>&lt;p&gt;I recently stumbled upon an example for how to include "trendlines" in kusto queries that might be handy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exceptions
| where timestamp &amp;gt; ago(90d)
| summarize c = log(count()) by bin(timestamp, 1d)
| as hint.materialized=true T
| extend _perc_25 = toscalar(T | summarize percentile(c, 25)),
         _perc_50 = toscalar(T | summarize percentile(c, 50)),
         _perc_75 = toscalar(T | summarize percentile(c, 75))
| render timechart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kusto</category>
      <category>appinsights</category>
    </item>
    <item>
      <title>Resend Azure Service Bus topic message</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Mon, 10 Jul 2023 17:11:03 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/resubmit-azure-service-bus-topic-message-3den</link>
      <guid>https://dev.to/jonassamuelsson/resubmit-azure-service-bus-topic-message-3den</guid>
      <description>&lt;p&gt;In this post I'm going to take a look at one of the implications of resubmitting azure service bus subscription dead letter messages and how it can be solved.&lt;/p&gt;

&lt;p&gt;Azure service bus has two kind of messaging entities, queues and topics. We wont go deep into the difference of the two here but basically a queue has a single logical consumer while a a topic can have multiple logical consumers (subscriptions). Microsoft docs available &lt;a href="https://learn.microsoft.com/en-us/dotnet/api/overview/azure/messaging.servicebus-readme?view=azure-dotnet#key-concepts"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A message sent to a topic is distributed to all configured subscriptions. And each subscription has its own dead letter queue where messages are placed if the can't be consumed within the specified retry count.&lt;/p&gt;

&lt;p&gt;It would be nice to resend a dead letter message back to its subscription but that can't be done. No messages (new or dead letters) can be sent directly to a subscription, they have to be sent to the topic.&lt;/p&gt;

&lt;p&gt;But this means that the message will be distributed to both subscriptions. If you have written your message handlers to be idempotent, meaning that they can handle the same message twice, there is no problem and you can stop reading now but if that isn't something you can guarantee you're in a bit of a problem. As we were.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/topic-filters"&gt;Filters&lt;/a&gt; to the rescue.&lt;/p&gt;

&lt;p&gt;Filters can be applied to a subscription to make sure that only messages that fulfills a given criteria is handled by the subscription (messages that don't fulfill the criteria are dropped).&lt;/p&gt;

&lt;p&gt;We applied filters to all our subscriptions so that it only process messages where a header called &lt;code&gt;TargetSubscription&lt;/code&gt; either doesn't exist or contains the name of the subscription.&lt;/p&gt;

&lt;p&gt;Since we use &lt;a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview?tabs=bicep"&gt;bicep&lt;/a&gt; to deploy our azure infrastructure it was fairly easy to create a module for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resource r 'Microsoft.ServiceBus/namespaces/topics/subscriptions/rules@2021-11-01' = [for subscription in subscriptions: {
  name: '${namespace}/${subscription.topicName}/${subscription.name}/default'
  dependsOn: [
    s
  ]
  properties: {
    filterType: 'SqlFilter'
    sqlFilter: {
      sqlExpression: 'TargetSubscription is null or TargetSubscription = \'\' or TargetSubscription = \'${subscription.name}\''
    }
  }
}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this in place it now becomes fairly trivial to send messages to a specific subscription.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>servicebus</category>
    </item>
    <item>
      <title>dotnet assembly binding redirects</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Wed, 14 Sep 2022 13:20:17 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/dotnet-assembly-binding-redirects-5dpj</link>
      <guid>https://dev.to/jonassamuelsson/dotnet-assembly-binding-redirects-5dpj</guid>
      <description>&lt;p&gt;In order to add the correct assmbly binding redirects in full framework projects, add this project setting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;AutoGenerateBindingRedirects&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/AutoGenerateBindingRedirects&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then do a clean / rebuild with warnings enabled and double click the related warning.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>kusto - filter by custom dimension keys</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Tue, 13 Sep 2022 10:11:23 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/kusto-filter-by-custom-dimension-keys-167</link>
      <guid>https://dev.to/jonassamuelsson/kusto-filter-by-custom-dimension-keys-167</guid>
      <description>&lt;p&gt;I sometimes want to filter app insights entries based on whether a custom dimension exists or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/mvexpandoperator"&gt;&lt;code&gt;mv-expand&lt;/code&gt;&lt;/a&gt; to the rescue 😃&lt;/p&gt;

&lt;p&gt;The query below returns requests containing a custom dimension starting with the string &lt;code&gt;toggle:&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;requests
| extend dimension = bag_keys(customDimensions)
| mv-expand dimension
| where dimension startswith "toggle:"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>appinsights</category>
      <category>kusto</category>
    </item>
    <item>
      <title>kusto &amp; concat string array</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Thu, 07 Jul 2022 10:34:31 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/kusto-concat-string-array-an9</link>
      <guid>https://dev.to/jonassamuelsson/kusto-concat-string-array-an9</guid>
      <description>&lt;p&gt;From time to time I want to summarize a kusto query by a combination of multiple values.&lt;/p&gt;

&lt;p&gt;One way to do that is to concat them all manually, like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strcat(cloud_RoleName, "-", application_Version, "-", resultCode)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During investigations I often want to change which values I group by and writing the query like this simplifies that&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;strcat_array(pack_array(cloud_RoleName, application_Version, resultCode), "-")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>kusto</category>
      <category>applicationinsights</category>
    </item>
    <item>
      <title>dotnet restore --interactive not prompting</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Mon, 06 Sep 2021 11:22:17 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/dotnet-restore-interactive-not-prompting-36k1</link>
      <guid>https://dev.to/jonassamuelsson/dotnet-restore-interactive-not-prompting-36k1</guid>
      <description>&lt;p&gt;I recently had a situation where doing &lt;code&gt;dotnet restore&lt;/code&gt; from the command line resulted in 401 responses and adding the &lt;code&gt;--interactive&lt;/code&gt; didn't work to prompt for credentials.&lt;/p&gt;

&lt;p&gt;After some googling I found a &lt;a href="https://github.com/dotnet/sdk/issues/10189"&gt;github issue&lt;/a&gt; indicating that &lt;a href="https://github.com/microsoft/artifacts-credprovider"&gt;Microsofts Azure Artifacts Credential Provider&lt;/a&gt; should be installed / updated.&lt;/p&gt;

&lt;p&gt;TLDR; run &lt;code&gt;iex "&amp;amp; { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -Force"&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>cli</category>
    </item>
    <item>
      <title>git clone and long paths on windows</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Thu, 01 Jul 2021 14:11:16 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/git-clone-and-long-paths-on-windows-43on</link>
      <guid>https://dev.to/jonassamuelsson/git-clone-and-long-paths-on-windows-43on</guid>
      <description>&lt;p&gt;If you ever run in to the issue that you can't clone a git repo because it contains paths longer than 260 characters on windows run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;git&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--global&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;core.longpaths&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a registry entry for long paths as well but that doesn't help here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="s2"&gt;"LongPathsEnabled"&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dword&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;00000001&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Restart multiple azure app services</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Fri, 09 Apr 2021 07:28:57 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/restart-multiple-azure-app-services-1gc5</link>
      <guid>https://dev.to/jonassamuelsson/restart-multiple-azure-app-services-1gc5</guid>
      <description>&lt;p&gt;We sometimes need to restart all azure app services in a subscription or service plan. It's very time consuming to do manually in the portal as it has to be done per app service but using &lt;code&gt;az cli&lt;/code&gt; it's really easy. =)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;az&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;webapp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;convertfrom-json&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;foreach&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;az&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;webapp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;restart&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--ids&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="bp"&gt;$_&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>azure</category>
      <category>powershell</category>
      <category>azcli</category>
      <category>azureappservice</category>
    </item>
    <item>
      <title>azure devops pipeline predefined variables</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Tue, 02 Mar 2021 09:53:26 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/azure-devops-pipeline-predefined-variables-19oa</link>
      <guid>https://dev.to/jonassamuelsson/azure-devops-pipeline-predefined-variables-19oa</guid>
      <description>&lt;p&gt;Azure DevOps provides a number of &lt;a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables"&gt;predefined variables&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some of these are folders for your source files, artifacts, temp files, etc.&lt;br&gt;
And some of these variables maps to the same value.&lt;/p&gt;

&lt;p&gt;Here is a list of all the folder variables (on a window-2019 image):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent.BuildDirectory: D:\a\1
Agent.HomeDirectory: C:\agents\2.182.1
Agent.TempDirectory: D:\a\_temp
Agent.ToolsDirectory: C:\hostedtoolcache\windows
Agent.WorkFolder: D:\a
Build.ArtifactStagingDirectory: D:\a\1\a
Build.BinariesDirectory: D:\a\1\b
Build.Repository.LocalPath: D:\a\1\s
Build.SourcesDirectory: D:\a\1\s
Build.StagingDirectory: D:\a\1\a
Common.TestResultsDirectory: D:\a\1\TestResults
Pipeline.Workspace: D:\a\1
System.DefaultWorkingDirectory: D:\a\1\s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>azuredevops</category>
    </item>
    <item>
      <title>TF30063</title>
      <dc:creator>Jonas Samuelsson</dc:creator>
      <pubDate>Thu, 14 Jan 2021 06:26:51 +0000</pubDate>
      <link>https://dev.to/jonassamuelsson/tf30063-46md</link>
      <guid>https://dev.to/jonassamuelsson/tf30063-46md</guid>
      <description>&lt;p&gt;From time to time I have to work with projects using Azure DevOps TFVC.&lt;br&gt;
It is fairly common that I get a TF30063 error in the Team Explorer, saying I'm unauthorized and need to reenter my credentials. But unfortunately that doesn't help.&lt;/p&gt;

&lt;p&gt;I just found a &lt;a href="https://developercommunity.visualstudio.com/content/problem/630870/tf30063-authorization-error-when-opening-projects.html"&gt;visual studio developer community post&lt;/a&gt; containing the solution.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If Visual Studio is showing the &lt;code&gt;Team Explorer&lt;/code&gt; tab/panel, select the &lt;code&gt;Solution Explorer&lt;/code&gt; tab/panel.&lt;/li&gt;
&lt;li&gt;If Visual Studio had already been showing the &lt;code&gt;Solution Explorer&lt;/code&gt; tab, select the &lt;code&gt;Team Explorer&lt;/code&gt; tab and then select the &lt;code&gt;Solution Explorer&lt;/code&gt; tab again.&lt;/li&gt;
&lt;li&gt;Make sure that the &lt;code&gt;Solution Explorer&lt;/code&gt; tab is currently selected, and close this instance of Visual Studio (if I have other Visual Studio instances open that are connected to the on-premises TFS server, I leave those open).&lt;/li&gt;
&lt;li&gt;Re-open the same project (connected to Azure DevOps) in Visual Studio, and now everything seems to be fine.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>visualstudio</category>
    </item>
  </channel>
</rss>
