I creating an Azure Function app with ServiceBusTrigger
. I am running Visual Studio under an account which is also used to logging into Visual Studio.
I have added this user account under Service Bus Access Control & assigned Azure Service Bus Data Receiver
and Azure Service Bus Data Sender
roles.
[FunctionName("Function1")]
public void Run([ServiceBusTrigger("topic-one", "sub-one", Connection = "ServiceBusConnString")]string mySbMsg)
{
var credentail = new DefaultAzureCredential();
_logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
This is how local.settings.json file look:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"ServiceBusConnString__serviceUri": "https://sb-test-three.servicebus.windows.net/",
"ServiceBusConnString__fullyQualifiedNamespace": "https://sb-test-three.servicebus.windows.net/",
"ServiceBusConnString": "https://sb-test-three.servicebus.windows.net/ManagedIdentity",
"ConnectionString": "https://sb-test-three.servicebus.windows.net/"
}
}
I am getting below error when running the app locally using Visual Studio.
How can I run Azure function from Visual Studio using managed identity? I am not sure how to use DefaultAzureCredential class