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.