Edi Wang

Microsoft MVP for Azure

.NET C# Programming Language and .NET Platform

凑发票算法:经典背包问题的变种

在日常工作中,特别是报销或财务处理时,经常会遇到这样的问题:如何从一堆发票中找到金额满足某个值的最优组合?假设我们有一组发票,每张发票以文件名的形式存储,文件名包含发票金额,例如 酒店-996.35.pdf 打车-251.00 医疗-404.00 。我们的目标是从这些发票中,找到金额总和 至少等于目标金额 的最优组合,并且总金额尽可能接近目标金额。要解决这个问题,我们可以将其看作一个 背包问题的变种,即在给定一组发票的情况下,找到满足条件的金额组合。本文的算法采用 回溯法 来实现,逐步尝试每种可能的组合,并记录满足条件的最佳结果。
C# Algorithm

Understanding the "Efficient Shipping" Interview Question in C#

When preparing for interviews, you'll often come across optimization problems that test both your problem-solving skills and your ability to write efficient code. I have such an interesting programming interview question years ago. The Efficient Shipping problem. Let's break it down and analyze the solution. And to understand the flaws in the first version of my code and how we can improve it.
C# Algorithm

Migrating Moonglade.Email to Azure Communication Service

Moonglade.Email, is an Azure Function that originally relied on SMTP for sending emails. Microsoft implemented a change that prevents connections to both personal and enterprise Office 365 Outlook mailboxes. To ensure the email service continues functioning, I decided to integrate Azure Communication Services. In this blog post, I will explain how I implemented support for Azure Communication Services in the Moonglade.Email Azure Function.
.NET Azure Email Azure Function

Upload Files to Azure Blob Storage without Azure SDK

Typically, we use the Azure SDK to upload files to Azure Blob Storage, as it is the easiest method supported by Microsoft. However, there are situations where the Azure SDK might not be available. So, how can we still upload files to Azure Blob Storage in such cases? In this post, I will guide you through the steps to upload files to your Azure Storage Account without using the Azure SDK.
Azure Azure Blob Storage

Solving NuGet Package Target Naming Conflict

In my ASP.NET Core project, I encountered an issue where files from the tinymce NuGet package were not being copied to the wwwroot\lib directory during the build process, despite referencing both tinymce and Moonglade.MonacoEditor packages. Each package included a .targets file with a Target named CopyScriptsToProject, resulting in a conflict where the latter target overwrote the former, causing only Moonglade.MonacoEditor files to be copied. To resolve this, I renamed the targets in each .targets file to ensure uniqueness.
.NET NuGet

Json Serialization Caveat in Azure Function

Creating Azure Functions using C# and .NET can feel quite familiar to those versed in creating ASP.NET Core Web APIs. Despite the similarities, one key difference lies in the process of JSON serialization, which can present unexpected challenges. In this post, I'll explore the two most common issues developers encounter with JSON in Azure Functions and provide practical solutions to overcome them. …
.NET Json Azure

How to Detect If Your Application is Running in Azure App Service

An application needs to know if itself is running in Azure App Service, so that it can apply special logic and optimization for Azure. When deploying an application to Azure App Service, the platform automatically assigns a set of environment variables that can be accessed by the application code. In this post, we will see how can our application get this information. …
.NET Azure App Service

Call API with Windows Authentication from Blazor Web Assembly

I was rewriting an old Angular application to Blazor Web Assembly a couple of days ago. The App is an internal tool, which uses a backend API that has Windows Authentication. However, when calling API from HttpClient that UseDefaultCredentials, Blazor will throw PlatformNotSupportedException. The majority of internet search so far tell you it's not possible. Really? Let's see how to make it work! …
.NET Web API Blazor