I was recently trying to manage Azure SQL Databases via Visual Studio in a new Azure subscription and was unable to open the SQL Databases node at all and received the following error message.
The text reads:
Error 0: Failed to retrieve all server data for subscription ‘GUID’ due to error ‘Error code: 403 Message: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.’.
and my Server Explorer window looked like this:
I must admit that I don’t often manage my Azure assets via Visual Studio so it had been a while since I’d used this tooling. I tried a few ways to get this to work and double checked that I had the right details for the subscription registered on my local machine. Storage worked fine, Virtual Machines worked fine… everything looked good except SQL Databases!
(At this point I’d say… hint: I should have read the error message more closely!)
After some additional troubleshooting it turns out that unlike many other Azure offerings, Azure SQL Database does not support OAuth-based connections and instead uses certificates (you know, like the error message says…).
Unfortunately, it turns out that if you have an expired or otherwise invalid certificate for any Azure subscription registered then Visual Studio will fail to enumerate SQL Database instances in the subscription you are currently using even if its certificate is fine.
The use of a subscription GUID isn’t that helpful when troubleshooting because I completely missed that the problematic certificate wasn’t even from the subscription I was currently trying to use!
You can fix this issue by managing your registered Azure subscriptions from within Visual Studio as follows.
- Right-click on the top Azure node in Server Explorer.
- Select Manage Subscriptions… from the menu.
- Click on the “Certificates” tab and find the Subscription with the GUID matching the error.
- Click “Remove…” and then close the dialog.
You should now be able to open the Azure SQL Database node in Server Explorer and manage them as you expect!