Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not intuitive how to provide managed identity token #549

Closed
ramonsmits opened this issue Oct 17, 2022 · 3 comments
Closed

Not intuitive how to provide managed identity token #549

ramonsmits opened this issue Oct 17, 2022 · 3 comments

Comments

@ramonsmits
Copy link
Member

It is not very intuitive on how to provide a managed identity token. The following snippet shows how this can be achieved when using 4.0.0-rc.2:

[assembly:NServiceBusTriggerFunction("test")]
public class Program
{
    public static void Main()
    {
        var host = new HostBuilder()
            .ConfigureFunctionsWorkerDefaults()
            .UseNServiceBus(configuration =>
            {
                var endpointConfiguration = configuration.AdvancedConfiguration;
                var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
                transport.ConnectionString("[namespace].servicebus.windows.net");
                transport.CustomTokenCredential(new DefaultAzureCredential());
            })
            .Build();

        host.Run();
    }
}
@ramonsmits
Copy link
Member Author

The following shows how to obtain FQDN from the environment: #390

@shawnz88
Copy link

shawnz88 commented Oct 17, 2022

In 4.0.0-rc.2 the minimal working code is:

Program.cs:

public static async Task Main()
    {
        var host = new HostBuilder()
            .ConfigureFunctionsWorkerDefaults()
            .UseNServiceBus("endpointname", "[namespace].servicebus.windows.net", configuration =>
            {
                configuration.Transport.TokenCredential = new DefaultAzureCredential();
            })
            .Build();

        await host.RunAsync();
    }

local.settings.json:

"AzureWebJobsServiceBus": "Endpoint=sb://[your_namespace].servicebus.windows.net/;Authentication=ManagedIdentity",
"ServiceBus__fullyQualifiedNamespace": "[your_namespace].servicebus.windows.net",

@andreasohlund
Copy link
Member

andreasohlund commented May 30, 2024

Closing as a duplicate of #390

@andreasohlund andreasohlund closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants