1

I am running an azure function with Service Bus trigger on Visual Studio. I have added my account (using email) in Visual Studio 2022 using Tools > Options > Azure Service Authentication. I have added this user account in Azure service bus using Access Control (IAM) and given it Azure Service Bus Data Sender & receiver roles.

This is what the Azure function looks like:

[FunctionName("FunctionWthMI")]
public void Run([ServiceBusTrigger("topic-one", "sub-one", Connection = "ServiceBusConnection")]string mySbMsg)
{
    var credential = new DefaultAzureCredential();
    _logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}

This is how the setting looks:

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "ServiceBusConnection:fullyQualifiedNamespace": "sb-test-three.servicebus.windows.net",
        "ServiceBusConnString": "Endpoint=sb://sb-test-three.servicebus.windows.net/;Authentication=ManagedIdentity",
        "connectionString": "Endpoint=sb://sb-test-three.servicebus.windows.net/;Authentication=Managed Identity"
    }
}

I followed this link https://learn.microsoft.com/en-us/azure/azure-functions/functions-identity-based-connections-tutorial-2#connect-to-service-bus-in-your-function-app to set ServiceBus Connection string.

After running the app I am getting following error:

Timestamp: 2022-10-01 15:16:01Z'.) (Stored credentials not found. Need to authenticate user in VSCode Azure Account. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/vscodecredential/troubleshoot) (Azure CLI not installed) (Az.Account module >= 2.2.0 is not installed.). System.Private.CoreLib: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/environmentcredential/troubleshoot

I have installed Azure-CLI locally along with Azure function core tools on my machine.

I have logged out and logged into Visual Studio subscription.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
OpenStack
  • 5,048
  • 9
  • 34
  • 69
  • have you tried `ServiceBusConnection__fullyQualifiedNamespace` locally ? It happened to work for me – Thomas Oct 01 '22 at 20:56
  • @Thomas: Yes, as lot of articles suggested it. I get following error: `[2022-10-01T20:58:35.681Z] Timestamp: 2022-10-01 20:58:18Z'.) (Stored credentials not found. Need to authenticate user in VSCode Azure Account. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/vscodecredential/troubleshoot) (Please run 'az login' to set up account) (Az.Account module >= 2.2.0 is not installed.). System.Private.CoreLib: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. ` – OpenStack Oct 01 '22 at 21:00
  • @Thomas: is your use case same ? where you are trying to access service bus topic messages using azure function with managed identity ? If yes, can you please share more details as the answer this question. – OpenStack Oct 01 '22 at 21:01
  • 1
    looks like your credential have expired ? Can you check in Tools > Options > Azure Service Authentication ? If expired, you should see a message saying re-enter your credentials – Thomas Oct 01 '22 at 21:11
  • @Thomas: Thank you for suggestion. Token is not expired. I also logged out and logged in back and no luck. – OpenStack Oct 02 '22 at 12:45

0 Answers0