microsoft / azuredatastudio

Azure Data Studio is a data management and development tool with connectivity to popular cloud and on-premises databases. Azure Data Studio supports Windows, macOS, and Linux, with immediate capability to connect to Azure SQL and SQL Server. Browse the extension library for more database support options including MySQL, PostgreSQL, and MongoDB.
https://learn.microsoft.com/sql/azure-data-studio
MIT License
7.52k stars 894 forks source link

AzureMonitor ext - The provided authentication is not valid for this resource #24798

Open wsmelton opened 10 months ago

wsmelton commented 10 months ago

Type: Bug

  1. Install extension
  2. Authenticate to Azure tenant to list resources
  3. Drill into subscription
  4. Right-click LAW
  5. Select Manager
  6. Enter name
  7. Connect
  8. Error received
System.Exception: The Log Analytics Workspace can not be reached. Please validate the Workspace ID, the correct tenant is selected, and that you have access to the workspace. 
Error Message: The provided authentication is not valid for this resource

   at Microsoft.Kusto.ServiceLayer.DataSource.Monitor.MonitorClient.LoadMetadata(Boolean refresh) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\Monitor\MonitorClient.cs:line 64
   at Microsoft.Kusto.ServiceLayer.DataSource.Monitor.MonitorIntellisenseClient..ctor(MonitorClient monitorClient) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\Monitor\MonitorIntellisenseClient.cs:line 17
   at Microsoft.Kusto.ServiceLayer.DataSource.DataSourceFactory.Create(ConnectionDetails connectionDetails, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\DataSourceFactory.cs:line 44
   at Microsoft.Kusto.ServiceLayer.Connection.ReliableDataSourceConnection..ctor(ConnectionDetails connectionDetails, RetryPolicy connectionRetryPolicy, RetryPolicy commandRetryPolicy, IDataSourceFactory dataSourceFactory, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\ReliableDataSourceConnection.cs:line 65
   at Microsoft.Kusto.ServiceLayer.Connection.DataSourceConnectionFactory.CreateDataSourceConnection(ConnectionDetails connectionDetails, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\Connection\DataSourceConnectionFactory.cs:line 36
   at Microsoft.Kusto.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\Connection\ConnectionService.cs:line 402

The details for connection documented here are not all available in current version: https://learn.microsoft.com/en-us/azure-data-studio/extensions/azure-monitor-logs-extension#connection-details

image

Clicking on Advanced... shows an empty window, nothing is loaded.

I am the owner of the subscription, and the Log Analytics Workspace. I can query this workspace from the portal or via Azure PowerShell with the same credential being used in ADS.

Extension version: 0.1.9 Azure Data Studio version: azuredatastudio-insiders 1.47.0-insider (9f6ec2fe0d866f8ce0d5a29feb41432d0d9ecf56, 2023-10-26T05:34:45.530Z) OS version: Darwin arm64 21.6.0 Restricted Mode: No Preview Features: Enabled Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|5, 4, 4| |Memory (System)|32.00GB (0.81GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
theonlyames commented 9 months ago

I am running into the same issue, on the USGovernment Cloud.

System.Exception: The Log Analytics Workspace can not be reached. Please validate the Workspace ID, the correct tenant is selected, and that you have access to the workspace. 
Error Message: The provided authentication is not valid for this resource

   at Microsoft.Kusto.ServiceLayer.DataSource.Monitor.MonitorClient.LoadMetadata(Boolean refresh) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\Monitor\MonitorClient.cs:line 64
   at Microsoft.Kusto.ServiceLayer.DataSource.Monitor.MonitorIntellisenseClient..ctor(MonitorClient monitorClient) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\Monitor\MonitorIntellisenseClient.cs:line 17
   at Microsoft.Kusto.ServiceLayer.DataSource.DataSourceFactory.Create(ConnectionDetails connectionDetails, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\DataSourceFactory.cs:line 44
   at Microsoft.Kusto.ServiceLayer.Connection.ReliableDataSourceConnection..ctor(ConnectionDetails connectionDetails, RetryPolicy connectionRetryPolicy, RetryPolicy commandRetryPolicy, IDataSourceFactory dataSourceFactory, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\DataSource\ReliableDataSourceConnection.cs:line 65
   at Microsoft.Kusto.ServiceLayer.Connection.DataSourceConnectionFactory.CreateDataSourceConnection(ConnectionDetails connectionDetails, String ownerUri) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\Connection\DataSourceConnectionFactory.cs:line 36
   at Microsoft.Kusto.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\1\s\src\Microsoft.Kusto.ServiceLayer\Connection\ConnectionService.cs:line 402
elvovsky commented 6 months ago

I also have the same issue on windows 10. Extension version 0.1.9 . Azure data studio 1.47.1

devbar commented 6 months ago

I have the same issue after working a couple of days successfull with the tool.

EDIT: Removing the file Locat State and machineid from C:\Users\\AppData\Roaming\azuredatastudio was a workaround for me

robertplata commented 5 months ago

I am experiencing the same issue - Azure Data Studio 1.47.1. Azure Monitor Logs extension version 0.1.9. Windows 11 Enterprise, version 10.0.22631.

A co-worker was able to connect successfully on an older version of Azure Data Studio.

The workaround mentioned by devbar did not work for me.

richardswinbank commented 3 months ago

I also have the same issue; ADS 1.48.0, Azure Monitor Logs v0.1.9, Windows 11 Pro v10.0.22631. @cheenamalhotra I see this was added to the backlog back in November — do you know when a fix might appear in a release please?

wsmelton commented 3 months ago

Upvoting or hitting the 👍🏻 on the original post I recall helps prioritize for this team

blarsern commented 2 months ago

Actually found a solution. Shut down studio. Go to: C:\Users\\AppData\Roaming\azuredatastudio\Azure Accounts Remove accessTokenCache.local and accessTokenCache Start, click your connection and then i got a dropdown who asked someting about use Grant or Code something. I choosed grant.

Then it finally connected.

Let's see how long it lasts..


Same problem her, i have no solution or workaround for this. Can't connect our log analytics anymore. devbar solution does not work.