Edi Wang

.NET and Azure Developer

Posts in May 2021

ASP.NET Core Unit Test: How to Mock HttpClient.GetStringAsync()

In ASP.NET Core unit tests, if you want to mock HttpClient.GetStringAsync(), here's the trick. Problem Given the following code var html = await _httpClient.GetStringAsync(sourceUrl); When I tried to mock HttpClient.GetStringAsync() like this var httpClientMock = new Mock<HttpClient>(); httpClientMock .Setup(p => p.GetStringAsync(It.IsAny<string>())) .Returns(Task.FromResult("...")); Moq …
ASP.NET Unit Test

How to Prevent Access to App Service Url Behind Azure Front Door

In my previous posts, I have introduced usage of Azure Front Door. However, when we finish setting up the front door and bind our domain to the front door, users can still access the App Service URL. In this post, I'll introduce how to prevent access to our App Service when using Azure Front Door. Problem For example, my blog is binding https://edi.wang to my front door, I have 2 App Services …
Azure App Service Front Door