<?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: kosmos</title>
    <description>The latest articles on DEV Community by kosmos (@kosmosebi).</description>
    <link>https://dev.to/kosmosebi</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%2F41995%2Fa8fe10d5-92d7-4ecb-9df4-6adea5f109af.png</url>
      <title>DEV Community: kosmos</title>
      <link>https://dev.to/kosmosebi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kosmosebi"/>
    <language>en</language>
    <item>
      <title>Handle authentication when using Azure SDKs in .NET (C#)</title>
      <dc:creator>kosmos</dc:creator>
      <pubDate>Thu, 26 Jun 2025 18:34:49 +0000</pubDate>
      <link>https://dev.to/kosmosebi/handle-authentication-when-using-azure-sdks-in-net-c-5h75</link>
      <guid>https://dev.to/kosmosebi/handle-authentication-when-using-azure-sdks-in-net-c-5h75</guid>
      <description>&lt;p&gt;When using official Azure SDKs in .NET (C#), you typically create a client first and pass the Credential to it. This time, I want to tweak that part a bit.&lt;/p&gt;




&lt;p&gt;A common approach is to use ApiKeyCredential, where you pass the API key string. For example, something like the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AzureOpenAIClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;openai_endpoint&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;ApiKeyCredential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Azure-related scenarios, when using Managed Identities or relying on local Azure CLI authentication information, you typically use DefaultAzureCredential as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AzureOpenAIClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;openai_endpoint&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;DefaultAzureCredential&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time, it's about how to handle situations when those scenarios don't fit. Here is a concrete example. Suppose you are using Azure OpenAI Service and aggregating API entry points with Azure API Management (APIM). Also, access from APIM to Azure OpenAI Service itself uses Managed Identities.&lt;br&gt;
In this situation, when a user (client app) accesses APIM, you want to use a JWT access token obtained by the app to verify and determine access permission in APIM.&lt;br&gt;
Inside the app, regardless of OpenAI, there might be an access token that allows access to, for example, an internal API server, and you want to use that to call Azure OpenAI managed by APIM. (Let's ignore the idea of handling this with Azure OpenAI's IAM for now. It can be troublesome if the account tenant and resource tenant differ, and you don't want to mess with IAM for just ordinary usage without privileges.)&lt;/p&gt;

&lt;p&gt;So, what should you do when you already have an access token? The conclusion is that you can create and implement a custom TokenCredential by inheriting from Azure.Core.TokenCredential.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomCredential&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Azure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TokenCredential&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="n"&gt;AccessToken&lt;/span&gt; &lt;span class="nf"&gt;GetToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TokenRequestContext&lt;/span&gt; &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"your custom token"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DateTimeOffset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UtcNow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHours&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;ValueTask&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetTokenAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TokenRequestContext&lt;/span&gt; &lt;span class="n"&gt;requestContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;cancellationToken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AccessToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"your custom token"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;DateTimeOffset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;UtcNow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHours&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You just create a class like that and pass it instead of other Credentials.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AzureOpenAIClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;openai_endpoint&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;CustomCredential&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, GetToken()/GetTokenAsync() will be called when necessary, so it's fine to appropriately provide the access token or similar. If you also pass the RefreshOn argument, it should handle the update process (including re-calls) as needed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/api/azure.core.tokencredential?view=azure-dotnet&amp;amp;preserve-view=true#definition" rel="noopener noreferrer"&gt;TokenCredential Class&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, it is less troublesome to use derived classes of TokenCredential provided by the SDK or DefaultAzureCredential, but this is another possible approach. As a side note, since DefaultAzureCredential chains credentials, if the operating environment is fixed, such as deploying on Azure in a Release build, it is more efficient to pass ManagedIdentityCredential or fix it without chaining, as this reduces overhead.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication/credential-chains?tabs=dac" rel="noopener noreferrer"&gt;Credential chains in the Azure Identity library for .NET&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Find the alternative solutions about cloud-based load testing features</title>
      <dc:creator>kosmos</dc:creator>
      <pubDate>Wed, 03 Jun 2020 20:22:05 +0000</pubDate>
      <link>https://dev.to/kosmosebi/find-the-alternative-solutions-about-cloud-based-load-testing-features-5g3a</link>
      <guid>https://dev.to/kosmosebi/find-the-alternative-solutions-about-cloud-based-load-testing-features-5g3a</guid>
      <description>&lt;p&gt;Last year, Microsoft said discontinue cloud-based load testing features in Microsoft services such as &lt;a href="https://docs.microsoft.com/en-us/azure/devops/test/load-test/getting-started-with-performance-testing?view=azure-devops" rel="noopener noreferrer"&gt;Visual Studio&lt;/a&gt; and &lt;a href="https://docs.microsoft.com/en-us/azure/devops/test/load-test/app-service-web-app-performance-test?view=azure-devops&amp;amp;viewFallbackFrom=azure-devop" rel="noopener noreferrer"&gt;Azure DevOps&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://azure.microsoft.com/en-us/updates/cloud-based-load-testing-features-will-be-retired-on-march-31-2020/" rel="noopener noreferrer"&gt;Cloud-based load testing features will be retired on March 31, 2020&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to alternative solution and you like &lt;a href="https://jmeter.apache.org/" rel="noopener noreferrer"&gt;Apache JMeter&lt;/a&gt;, you can get our solutions from Azure Marketplace.&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%2Fi%2Flohg5ko2mtco9c5en763.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%2Fi%2Flohg5ko2mtco9c5en763.png" alt="JMeter in marketplace" width="800" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This service provide Apache JMeter server to your environment on Azure. You can start load test easily after deploy process. If you want to high-load, you will chose multiple remote servers version. You do not need complicated configure for servers.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.pnop.co.jp/azure-marketplace-apache-jmeter-multiple-users-manual/" rel="noopener noreferrer"&gt;How to use&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's enjoy cloud-based load testing.&lt;/p&gt;

</description>
      <category>azure</category>
    </item>
    <item>
      <title>Is your Visual Studio using hardware graphics acceleration in Visual Studio?</title>
      <dc:creator>kosmos</dc:creator>
      <pubDate>Mon, 08 Jul 2019 19:11:32 +0000</pubDate>
      <link>https://dev.to/kosmosebi/is-your-visual-studio-using-hardware-graphics-acceleration-in-visual-studio-44m4</link>
      <guid>https://dev.to/kosmosebi/is-your-visual-studio-using-hardware-graphics-acceleration-in-visual-studio-44m4</guid>
      <description>&lt;p&gt;Recent versions Visual Studio can support hardware graphics acceleration. In normally, that is automatically enabled it in your computer if your computer can support GPU. However some situation doesn't enabled it automatically when has enabled Hyper-V in your computer.&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%2Fxkxguw9jitjv3dn1b750.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%2Fxkxguw9jitjv3dn1b750.png" alt="Fig.1" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig.1: Automatically option is enable, but Visual Studio using software rendering.&lt;/p&gt;

&lt;p&gt;If your computer can use GPU and enabled Hyper-V, you should checked off  "Automatically adjust visual experience based on client performance", and checked on "Use hardware graphics acceleration if available".&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%2Fvl4ax0zz1p2q9plfy8zu.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%2Fvl4ax0zz1p2q9plfy8zu.png" alt="Fig.2" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This issue is known issue in VSteam. I'm looking forward to fix it. :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developercommunity.visualstudio.com/content/problem/583517/use-hardware-graphics-acceleration-if-available-op.html" rel="noopener noreferrer"&gt;Visual Studio developer community&lt;/a&gt;&lt;/p&gt;

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