tag:blogger.com,1999:blog-85203803344677773602024-03-20T01:31:01.786+13:00Jaliya's BlogJaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.comBlogger660125tag:blogger.com,1999:blog-8520380334467777360.post-73031584547827057942024-03-19T22:20:00.002+13:002024-03-19T22:20:44.683+13:00App Service Outbound Traffic through VNet Gets 403 When Trying to Access Another App Service with Public Network Access Enabled, but has a Private Endpoint
In this post, let's go through an interesting scenario related to App Service
networking.
- App A: is integrated into VNet A.
App A: Networking
- App B: has Public network access enabled with
no access restrictions. But it has a Private Endpoint in
VNet B.
Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-15921907279172040892024-03-15T22:42:00.000+13:002024-03-15T22:42:58.320+13:00Read TLS/SSL Certificate in Azure App Service from C# Code
Recently I was updating an old .NET Core web application to .NET 8 and the
code was reading a certificate as follows.
private X509Certificate2 GetCertificateByThumbprint(string thumbprint){ X509Store store = new (StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-39959736203561831662024-03-11T20:45:00.000+13:002024-03-11T20:45:55.204+13:00Azure AD B2C: Call an External API Using Client Credentials in an User Journey
In this post, let's see how to call an external API using Client Credentials
in an Azure AD B2C User Journey.
I am assuming Azure AD B2C App Registration is already set up for the client
app with the necessary permission (scope access) to call the protected
API and you have noted down the Client ID, Client Secret, and the Scope.
Note: There are no additional actions toJaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-32136650333147421782024-03-01T10:53:00.001+13:002024-03-01T10:53:12.774+13:00Creating Integration Tests for Azure Functions
I wanted to have some integration tests for Azure Functions, especially for some complex durable functions. When you have durable functions and when you want to make
sure that the orchestrations are behaving as expected, having integration
tests is the only way to ensure that. And another important thing is I needed to be able to run these tests not just locally, but in a CI pipeline (Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-90889391783334880802024-02-20T19:41:00.002+13:002024-02-20T19:41:48.142+13:00.NET 8.0 Isolated Azure Functions: Binding Expressions that uses Azure App Configuration
In this post let's see how we can use binding expressions in an .NET
8.0 Isolated Azure Function and how to consume the binding expression values
from Azure App Configuration (AAC).
Binding expressions are basically something like this. Let's take a simple
ServiceBus trigger function.
[Function(nameof(ServiceBusTrigger))]public static void Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-77517825533584652932024-02-09T13:07:00.000+13:002024-02-09T13:07:07.826+13:00Azure DevOps Self-hosted Agent: NETSDK1045: The current .NET SDK does not support targeting .NET 8.0
Recently I have faced this issue in one of our Self-hosted agents in Azure
DevOps when a pipeline is trying to build a .NET 8.0 application.
C:\vsts-agent\_work\_tool\dotnet\sdk\5.0.405\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-9949059176392532482024-02-03T13:58:00.008+13:002024-02-03T13:59:26.015+13:00Azure AD B2C: Validating Output Claim from a Non-Self-Asserted Technical Profile
I had a requirement where I wanted to do an additional validation on a boolean claim value in an AAD
B2C user journey. If the boolean claim value is true, I wanted to move forward in the user journey. If the value is false, I wanted to short circuit the user journey and return an error. I couldn't use
Validation Technical Profiles, because the output claim I am validating Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-75682613375360043102024-02-01T08:03:00.001+13:002024-02-02T22:49:32.588+13:00.NET 8.0 Isolated Azure Durable Functions: Preserve Stack Order When Passing Between Orchestrators, Activities etc
In this post let's see how we can preserve Stack<T> order when it's getting passed between Orchestrators/Activities in a
.NET Isolated Azure Durable Function.
In Durable Functions in the .NET isolated worker,
the Serialization default behavior has changed from
Newtonsoft.Json to System.Text.Json.
I have already written a post about preserving Stack Order Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-32981792841157951422024-01-22T21:47:00.002+13:002024-01-23T17:40:18.687+13:00Monitoring Azure Durable Functions using Durable Functions Monitor
In this post let's have a look at a cool project that you might want to use if
you are working on Azure Durable Functions.
The project is
DurableFunctionsMonitor, it provides a UI for monitoring, managing, and debugging orchestration
instances in an Azure Durable Function App.
Durable Functions Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-90033540273971187802024-01-17T21:09:00.000+13:002024-01-17T21:09:30.990+13:00ASP.NET Core 8.0: Output Caching using Redis
With ASP.NET Core 8.0, now you can use Redis as your cache provider when
cashing responses. The default is in-memory cache.
In this post, let's see how you can use Redis for output caching.
First, we need to install Microsoft.AspNetCore.OutputCaching.StackExchangeRedis
NuGet package.
And then call AddStackExchangeRedisOutputCache to add Redis output caching Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-90547593357406794952024-01-14T17:33:00.000+13:002024-01-14T17:33:00.110+13:00HttpClient: Dynamically Add HttpMessageHandlers
In this post, let's have a look at how we can create a HttpClient
with HttpMessageHandlers that gets created at run time.
I was hoping IHttpClientFactory
would support that, but at least I couldn't find a way to get IHttpClientFactory to work with dynamic HttpMessageHandlers.
But luckily we have HttpClientFactory
static class and there we have&Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-44063181866831327122024-01-04T21:45:00.000+13:002024-01-04T21:45:25.529+13:00Reading Configuration using Different Options Patterns in ASP.NET Core
A few days ago I saw an interesting question where someone was asking what's
the preferred way to read some configuration, something like below.
{ "SomeSetting": { "Config": "Value" }}
Would you use,
1. IConfiguration
app.MapGet("/config", (IConfiguration configuration) =>{ return&Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-39129586451064658342023-12-20T21:12:00.012+13:002023-12-20T21:18:39.208+13:00.NET 8.0: [LogProperties] Attribute
There are a lot of improvements to Logging in
.NET 8.0, and in this post, let's have a look at the new LogProperties attribute.
Now we can use
LogProperties
attribute in log methods attributed with LoggerMessage attribute (introduced with .NET 6.0). It's available through Microsoft.Extensions.Telemetry.Abstractions NuGet package.
Consider the Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-6472012721040357062023-12-12T04:10:00.001+13:002023-12-12T04:10:46.729+13:00LINQ: let Clause
In this post, let's see what let is in LINQ query-syntax queries. I think it's an overlooked feature in LINQ.
Let's consider the following query.
IQueryable<string> wfhEmployees = from e in context.Employees &Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-52708980021279474522023-12-10T07:22:00.000+13:002023-12-10T07:22:02.663+13:00EF Core 8.0: Better Use of IN Queries
When we are using Contains
LINQ operator in an EF subquery, EF Core now generates better queries
using SQL
IN
instead of
EXISTS. This can result in dramatically faster queries.
Let's go by an example.
Consider the following
DbContext.
public class MyDbContext : DbContext{ public DbSet<Employee> Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-70616692153328123562023-12-06T22:58:00.004+13:002023-12-06T23:01:11.369+13:00ASP.NET Core 8.0: Securing Swagger UI Endpoints
With ASP.NET Core 8.0, now you can secure Swagger UI endpoints by
calling MapSwagger().RequireAuthorization.
Consider the following code example.
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer();builder.Services.AddSwaggerGen(); builder.Services.AddAuthorization();builder.Services.AddAuthentication("Bearer"Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-30156489360194379482023-11-22T21:48:00.002+13:002023-11-22T21:48:29.031+13:00ASP.NET Core 8.0: Keyed Services in Dependency Injection
There are often times that we have different implementations of an interface
and we need to resolve a particular implementation when doing dependency
injection.
With ASP.NET Core 8.0, we now have support for Keyed Services.
Consider the following interface and its implementations.
public interface IMyService{ string GetValue();} public&Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-38237168955623033592023-11-21T19:50:00.001+13:002023-11-21T19:50:32.279+13:00Visual Studio 2022 17.9.0 Preview 1.0: Experimental Control Styles
Last week during .NET Conf there were some great announcements in the world of
.NET, and also Microsoft has released the latest preview of
Visual Studio 2022 17.9.0 Preview 1.0.
With the latest Visual Studio 2022 Preview, we now get to experience the
refreshed Visual Studio UI that the Visual Studio team has been working on for
some time.
To enable the UI Refresh, from Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-77630042346376234472023-11-06T20:29:00.002+13:002023-11-21T21:29:27.962+13:00Azure API Management: Self-Signed Certificate Authentication with ASP.NET Core Web API Running in an Azure Web Apps for Containers
I recently spent quite an interesting time trying to get self-signed
Certificate Authentication working with ASP.NET Core Web API Running in Azure
Web Apps for Containers. The caller was an Azure API Management, that was
making a send-request as part of its policy, something like the following.
<send-request mode="new" response-variable-name="httpresponse" Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-51336738618722050062023-11-01T16:04:00.001+13:002023-11-01T16:04:54.838+13:00Azure API Management: Enriching Requests with Additional Headers and Use of Caching
In this post let's see how we can customize Azure API Management (APIM)
Policy to enrich requests with additional headers and also let's look at how we can make
use of caching.
The demo scenario is as follows:
I have an example BE API, which requires a specific HTTP
Header: X-Tenant-Code, in order for it to serve.
A client sends a request with Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-69731776183137223342023-10-24T21:56:00.003+13:002023-11-21T21:29:35.842+13:00C# 12.0: Collection Expressions and Spread Operator
We are less than a month away from .NET 8 official release (.NET Conf 2023: November 14-16, 2023) and in this post, let's have a look at a nice feature in C# 12.0 which is getting shipped along with .NET 8.
You can try this feature with the latest preview of
Visual Studio 2022 (as of today it's 17.8.0 Preview 4.0). And remember to set LangVersion as Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-60297512619352763782023-10-19T05:57:00.002+13:002023-10-19T06:07:48.930+13:00Azure API Management: Adding Local Self-hosted Gateway
Azure API Management is made up of an API gateway, a management plane, and a
developer portal. In this post, let's see how we can add another API gateway
that is going to run locally on Docker to an APIM. So if we can have the API
gateway running locally, we can basically run it anywhere that supports
Containers, for example in Kubernetes, Azure Container Apps, etc.
Here what we are Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-58109876768782522072023-10-11T20:10:00.003+13:002023-11-21T21:29:46.184+13:00.NET 8 RC 2: IFormFile Support in [FromForm] in ASP.NET Core Minimal APIs
.NET 8 RC 2
was released today and we are just one month away from GA release.
With this release, in ASP.NET Core Minimal APIs, we can now pass IFormFile or IFormFileCollection when we are posting form fields that are getting bound via [FromForm] attribute.
Let's have a look at the following example where we are uploading a Single
file.
Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-29978503849969373512023-10-06T15:09:00.039+13:002023-11-21T21:29:53.653+13:00Calling an ASP.NET Core Web API Secured with Microsoft Entra ID using Azure Managed Identity
In this post, let's see how we can call an ASP.NET Core Web API Secured
with Microsoft Entra ID (known as Azure AD) using an Azure Managed Identity.
This is our scenario: we are going to have 2 APIs.
Internal API: This API is going to expose a GET: /claims endpoint. This endpoint will return
ClaimsPrinciple
Claims and will require Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0tag:blogger.com,1999:blog-8520380334467777360.post-37554360957997414932023-09-27T17:00:00.000+13:002023-09-27T17:00:08.228+13:00Visual Studio 2022 17.8.0 Preview 1.0: Case Preserving Find and Replace
In this post, let's have a look at some nice feature that got introduced
with Visual Studio 2022 17.8.0 Preview 1.0. Right now the latest Visual Studio preview is, Visual Studio 2022 17.8.0 Preview 2.0, so as long as you have a Visual Studio version
>= 17.8.0 Preview 1.0, you should be able to experience this
feature.
In the Replace popups, either Quick Replace (Jaliya Udagedarahttp://www.blogger.com/profile/00703574896769987385noreply@blogger.com0