question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Cannot get SQL databases

See original GitHub issue

Library name and version

Azure.ResourceManager.Sql 1.0.0-beta.4

Describe the bug

Following code:

await foreach (SqlDatabaseResource resource in sqlServer.GetSqlDatabases().GetAllAsync())
{
    Console.WriteLine("SQL db: " + resource);
}

results with a InvalidOperationException:

The requested operation requires an element of type 'Number', but the target element has type 'String'.

Expected behavior

Databases are listed

Actual behavior

Exception is thrown

Reproduction Steps

Just run this code:

try
{
     var subscription = subscriptions.Get(subscriptionId).Value;
     await foreach (var resource in subscription.GetResourceGroups().GetAllAsync())
     {
         Console.WriteLine("RG: " + resource.Data.Name);
     }

     var resourceGroup = subscription.GetResourceGroup(rgName).Value;
     await foreach (var resource in resourceGroup.GetSqlServers().GetAllAsync())
     {
         Console.WriteLine("SQL server: " + resource.Data.Name);
     }

    var sqlServer = resourceGroup.GetSqlServer(serverName).Value;
    await foreach (var resource in sqlServer.GetElasticPools().GetAllAsync())
    {
        Console.WriteLine("SQL ep: " + resource.Data.Name);
    }
    await foreach (SqlDatabaseResource resource in sqlServer.GetSqlDatabases().GetAllAsync())
    {
        Console.WriteLine("SQL db: " + resource);
    }
}
catch (InvalidOperationException e)
{
    Console.WriteLine(e.Message);
}

Environment

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
zhiweivcommented, Jun 9, 2022

1.0.0-beta.5 works now.

1reaction
fengzhou-msftcommented, Jun 8, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot connectivity issues in SQL Server
Provides an overview of common connectivity issues in SQL Server and describes the tools to troubleshoot the issues.
Read more >
SQL Server Login can't see databases
It sounds like you have removed the View Any Database permission from the Public role. If the Public role doesn't have the View...
Read more >
HOW TO FIX CANNOT CONNECT TO SQL SERVER ERROR
Verify that the instance name is correct and that SQL Server is ... click: https://docs.microsoft.com/ sql /relational- databases /errors-events ...
Read more >
Resolving could not open a connection to SQL Server errors
Go to the Connections tab and make sure Allow remote connections to this server is checked. If you need to make a change,...
Read more >
Error: 'Failed to connect to database' when attempting to ...
Answer. PROBLEM. When attempting to connect to a backend MS SQL Server database you receive an error similar to 'Failed to connect to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found