How to Fix Poor Sound Quality in Microsoft Teams or Other Communication Apps

If you experience poor sound quality while using a wireless headset with Microsoft Teams or other communication apps, the issue may be caused by a Windows audio setting — not the headset or the app itself.

Try this quick fix:

  1. Connect your wireless headset to your computer.
  2. Open Settings → System → Sound.
  3. Select your headset from the audio devices list.
  4. Open the device Properties or Advanced Settings.
  5. Find Audio Enhancements and set Device Default Effects to Off.
  6. Restart your computer if the sound does not improve immediately.

After changing this setting, your audio quality should be much clearer.

Note: This setting is applied separately for each audio device. If you connect a different headset in the future, you may need to repeat these steps.

How to fix: Issuer ciamlogin.com does not match any of the valid issuers provided for this application

Docker Network Issues Causing CIAM Authentication Errors

When running your application inside Docker, you may encounter authentication and OpenID configuration errors similar to the ones below:


IDX40001: Issuer: 'https://.ciamlogin.com/.../v2.0' does not match any of the valid issuers provided for this application.
InnerException: System.InvalidOperationException. Failed to validate the token.

IDX20803: Unable to obtain configuration from:
'https://.ciamlogin.com/.../v2.0/.well-known/openid-configuration'.
Will retry at '01/01/0001 00:00:00 +00:00'.

IDX20804: Unable to retrieve document from:
'https://.ciamlogin.com/.../v2.0/.well-known/openid-configuration'.
System.Net.Http.HttpRequestException: Network unreachable (.ciamlogin.com:443)

What Causes This?

These errors are typically related to Docker’s network configuration, particularly DNS resolution and IPv6 handling.
If Docker is attempting to resolve IPv6 (AAAA) records but your environment does not properly support IPv6,
the container may fail to reach the CIAM endpoint.

How to Fix It

To resolve the issue in Docker Desktop:

  1. Open Docker Desktop.
  2. Go to Settings.
  3. Navigate to Resources → Network.
  4. Under Default network mode, select IPv4 only.
  5. Under Inhibit DNS resolution for IPv4 / IPv6, select Filter IPv6 (AAAA records).
  6. Click Save.
  7. Restart Docker Desktop and all running containers.

Result

After applying these changes, your application should be able to properly resolve the CIAM endpoint
and successfully retrieve the OpenID configuration document.

How to Fix: “Another object with the same value for property proxyAddresses already exists.”

When creating a user in Azure Active Directory via code (e.g., Microsoft Graph API or PowerShell), you might encounter the following error:

“Another object with the same value for property proxyAddresses already exists.”

This message indicates that the email alias or proxy address you’re trying to assign is already in use, possibly by a deleted or hidden object. However, locating the conflicting object isn’t always straightforward—it might not even appear in the Azure Portal.

Step-by-Step Solution

1. Use Microsoft Graph Explorer
To find and resolve the conflict, you can use Microsoft Graph Explorer:
🔗 https://developer.microsoft.com/en-us/graph/graph-explorer

Tip: For best results, sign in with your tenant. You can do this directly using the following URL format:
https://developer.microsoft.com/en-us/graph/graph-explorer?tenant=yourtenant.onmicrosoft.com

Replace yourtenant with the name of your Azure AD tenant.

2. Run the Following Query
Once logged in, execute this GET request in Graph Explorer:

GET https://graph.microsoft.com/v1.0/users?$select=id,displayName,proxyAddresses,mail

This will return a list of users along with their proxyAddresses, mail, and displayName. Search through the results for the email address or alias that is causing the conflict.

3. What to Do Next
Once you’ve identified the conflicting user:

If the object is no longer needed, you can remove or update its proxyAddresses.

If it’s a soft-deleted user, you can use this query to search deleted users:

GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.user?$select=id,displayName,proxyAddresses,mail

From there, you may choose to permanently delete the user or restore it and update its values.

How to Fix ‘Resource Name Is Not Valid (Code: InvalidDomainName)’ with Your Custom Domain

Are you working on Bicep and implementing Microsoft.Communication/emailServices/domains? If you encounter the “Resource name is not valid (Code: InvalidDomainName)” error, make sure to specify your custom domain name in the name of the resource, like this:

resource emailServicesDomain 'Microsoft.Communication/emailServices/domains@2023-04-01-preview' = {
  name: 'mydomain.com' //your domain name
  location: 'global'
  parent: azureEmail
  properties: {
    domainManagement: 'CustomerManaged'
    userEngagementTracking: 'Disabled'
  }
}

Writing Unit Tests for Un-Testable Code: A Practical Approach

Consider a scenario where a developer needs to create a unit test for a method that generates a new GUID string (or any new object):

public string GetNewGuid()
{
     return Guid.NewGuid().ToString();
}

A junior developer might initially write a test like this:

        [Fact]
        public void GetNewGuid_VerifyGuid()
        {
            Business business = new Business();
            var expected = Guid.NewGuid().ToString();

            var val = business.GetNewGuid();
            Assert.Equal(val, expected);
        }

However, this test will fail on the Assert line because it relies on a freshly generated GUID for each call.

So, what’s the solution when dealing with code that uses the new statement? One approach is to utilize a simple Func delegate. Start by creating a Func delegate:

internal Func<string> NewGuid = () => Guid.NewGuid().ToString();

Then, replace the usage of Guid.NewGuid().ToString(); with this delegate:

        internal Func<string> NewGuid = () => Guid.NewGuid().ToString();
        public string GetNewGuid()
        {
            return NewGuid();
        }

Now, the trick is that you can inject your own implementation of NewGuid as needed. Here’s how you can modify the test:

        [Fact]
        public void GetNewGuid_ValidateGuid()
        {
            Business business = new Business();
            var expected = Guid.NewGuid().ToString();

            business.NewGuid = () => expected;

            var val = business.GetGuidTestable();
            Assert.Equal(val, expected);
        }

By assigning a new implementation to NewGuid, you can control the output for testing purposes.

Additionally, ensure you add the following two lines to the AssemblyInfo.cs file of the source project:

using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Business.Test")]

This allows access to internal members for testing purposes.

By employing this approach, developers can effectively create unit tests for code that involves the instantiation of new objects, enhancing the robustness and reliability of their software.

Demystifying Microsoft .NET Development Certificates: Locations and Password Retrieval

Have you ever wondered how to retrieve passwords from development .pfx files? If you’re working with Visual Studio, Microsoft has streamlined the process for managing your development certificates. These certificates are automatically generated and stored in the %APPDATA%/ASP.NET/Https folder, typically in the form of encrypted .pfx files. The critical question is: where can you find the corresponding passwords?

You can find the passwords in the %APPDATA%/Microsoft/UserSecrets folder. This folder contains multiple files with GUID names. But where do these GUIDs originate? They are sourced from your project’s .csproj file, which features a line like this:

<UserSecretsId>0cc51aff-9cdb-433a-a617-8800cc5d9a2a</UserSecretsId>

This unique identifier is the one you’re after. Locate the folder in %APPDATA%/Microsoft/UserSecrets with this GUID as its name and delve into it. There, you’ll find a JSON file named secrets.json. This file holds the certificate .pfx password in this format:

"Kestrel:Certificates:Development:Password": "0b27aff4-8e45-4783-9804-2f98c2803624"

With this password, you can now utilize the .pfx file and deploy it on a Linux box with ease.
In summary:

  1. Certificates are stored as .pfx files in %APPDATA%/ASP.NET/Https
  2. Passwords are stored in %APPDATA%/Microsoft/UserSecrets/[GUID]/secrets.json
  3. The GUID is specified in your .csproj file’s “ tag
  4. The password is in the "Kestrel:Certificates:Development:Password" key in secrets.json

Filter Dapr events in C# with Minimal API

Currently, my team is grappling with the challenge of filtering Dapr events. We have a scenario where one component needs to receive and process multiple similar events from another component, such as “file.uploaded,” “file.changed,” and “file.deleted.” While Dapr offers guidance in the article titled “How-To: Route messages to different event handlers,” we found it somewhat confusing and noticed that it doesn’t touch upon the integration with the Minimal API.

To address this, I’ve devised a solution comprising two key parts:

1. Prepare and Publish the CloudEvent:

When using the PublishEventAsync method, it’s crucial to include the “metadata” as outlined below:

CloudEvent message = new();
...
// Override cloudevent metadata
var metadata = new Dictionary() {
    { "cloudevent.source", message.Source },
    { "cloudevent.id", message.Id },
    { "cloudevent.type", message.Type }
};

await client.PublishEventAsync(pubsubName, key, message, metadata);

Omitting this parameter will result in the “event.type” being set to “com.dapr.event.sent.” See: Replace Dapr generated CloudEvents values

2. Capture the Event:

To capture the event effectively, you should first prepare the “TopicOptions” and then apply it using “.WithTopic”:

Dapr.TopicOptions topicOptionsUploadedFile = new()
{
    Match = "event.type==\"file.uploaded\"",
    PubsubName = daprSettings.PubsubName,
    Name = "mytopic"
};

app.MapPost("/processuploadedfile", (ILogger<Program> logger, CloudEvent<FileUploadedResponse> data) =>
{
    logger.LogInformation("Event called");
    return Results.Ok();
}).WithTopic(topicOptionsUploadedFile);

This approach ensures that events with the specified “event.type” (in this case, “file.uploaded”) are processed accordingly, allowing for effective event routing.

By following these two steps, you can better manage the filtration of Dapr events in your application.

Email sender’s username is invalid

Encountering the Error: ‘Email sender’s username is invalid. Please use a username from the list of valid usernames configured by your admin.’?

If you find yourself facing this error, fret not! We’ve got you covered with a simple step-by-step solution:
1. Head to the Azure Portal: Start by navigating to the Azure portal.
2. Search for “Email Communication Services”: Make use of the handy search feature in the Azure portal to quickly locate the “Email Communication Services” section.
3. Locate Your Service: Once you’re in the Email Communication Services area, find the specific service that’s giving you trouble.
4. Provision Domains: Click on your identified service and delve into the options. You’re on the right track if you find the “Provision domains” option – give it a click.
5. Choose Your Domain: From the list of available domains, select the one that’s causing you grief.
6. Navigate to “MailFrom Addresses”: Within your chosen domain’s settings, locate the “MailFrom addresses” option. This is where you’ll be making the necessary changes.
7. Add the Desired Address: Here’s where the fix happens. Add the desired email address to the list of addresses. This will ensure that the email sender’s username is considered valid and you’re good to go.

By following these steps, you’ll be well on your way to waving goodbye to that pesky error message.

Deploy Azure Container App with Environment Variables from Azure Table

The Azure Container App, based on consumption usage, is a very inexpensive way to build container apps in Azure. During development, you only pay for the usage of your container. However, there is one issue when deploying a container app: you have to specify your environment variables in the deployment string:

az config set extension.use_dynamic_install=yes_without_prompt --output none
az containerapp update  -n $MYAPP -g $MYGROUP --image $REPO:${GITHUB_SHA::8} --set-env-vars $ENV_VARIABLES_DEPLOYMENT --output none

The environment variables should be in a space-separated format, for example, a=b c=d e=f. One solution is to store the entire string in GitHub secrets. However, if you need to add or change any values, the admin has to replace the entire string.

A simpler solution is to store the variables in an Azure Table. Create an Azure storage account and add a table called MyTable. Then, create a new field called Value. Enter your environment variables, where the RowKey represents the variable name and Value represents the value of the environment variable. The PartitionKey can be set as your deployment environment. I recommend using one Azure table per environment.

To automate this process, you can create a GitHub action:

      - name: Build env variable
        run: |
          json_output=$(az storage entity query --table-name 'MyTable' --connection-string '${{ secrets.ENV_STORAGE_ACCOUNT_CONNECTION_STRING }}' --select "RowKey" "Value" --num-results 1000)
          formatted_output=$(echo "$json_output" | jq -r '.items[] | "\(.RowKey)=\(.Value)"' | tr '\n' ' ')  
          echo "ENV_VARIABLES_DEPLOYMENT=$formatted_output" >> $GITHUB_ENV
          echo "::add-mask::$formatted_output" # Mask the secret value in logs

Note that the last two lines add the formatted_output to the GitHub environment and mask the secret value in the logs.

Also, when using the az command, don’t forget to include --output none to avoid displaying a list of environment variables in the GitHub log.

Use https://github.com/marketplace/actions/install-jq to setup jq.

Structuring a NodeJS API Project: Best Practices for Organization, Scalability, and Testability

Recently, in my capacity as the CTO of Renet Consulting, I endeavored to identify the best practices for structuring a NodeJS API project. I found that there are limited resources available detailing folder structures that optimize both maintainability and testability. Although AI recommendations suggested segregating source code and tests into separate directories, this approach could present difficulties for less experienced developers when attempting to create unit tests. To strike a balance between maintainability and ease of testing, I recommend adhering to the following folder structure:

project/
├── node_modules/
├── src/
│   ├── controllers/
│   │   ├── auth.controller.js
│   │   └── auth.controller.spec.js
│   ├── middleware/
│   ├── models/
│   ├── services/
│   └── routes/
├── .env
├── .gitignore
├── package.json
└── README.md

For a significantly large application, I recommend dividing it using the following structure:

project/
├── node_modules/
├── src/
│   ├── controllers/
│   │  └─ auth/
│   │     ├── auth.controller.js
│   │     └── auth.controller.spec.js
│   ├── middleware/
│   ├── models/
│   ├── services/
│   └── routes/
├── .env
├── .gitignore
├── package.json
└── README.md