C#: Manage Azure SQL databases through Azure SDK in an Azure Function App

Viewed 27

I want to check parameters of different SQL databases and servers on a regular basis by using a Function App. This Function App should use the Azure SDK to retrieve the required parameters from Azure. Unfortunately, it is hard to find a working sample for that. I found this sample from MS on GitHub though.

So I tried to adapt it to my Function App like this:

    public void Run([TimerTrigger("0 30 * * * *", RunOnStartup = true)]TimerInfo myTimer, ILogger log, IAzure azure)
    {
        var list = azure.SqlServers.List();
    }

This does not work, of course as I need to somehow register the injected IAzure instance in my Startup.cs, this is the error message I get:

Cannot bind parameter 'azure' to type IAzure. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

So the question would be what I need to register in my Startup.cs file to get this working?

I tried this:

        builder.Services.AddAzureClients(clientBuilder =>
        {
            clientBuilder.UseCredential(new DefaultAzureCredential());
        });

but it does not make any difference.

0 Answers
Related