Datastore.register_azure_sql_database() return an error
Describe the bug A clear and concise description of what the bug is. Datastore.register_azure_sql_database() return an error: ase_name=os.getenv("SQL_DATBASENAME_62", "sqldb-demo") # Name of SQL database client_id=os.getenv("SQL_CLIENTNAME_62", "6d909b01-0512-4f95-97c6-b695b132fefd") # client id of service principal with permissions to access database client_secret=os.getenv("SQL_CLIENTSECRET_62", "bsWRt13Yxq00E+MM-txEw-Dmgz[74/lM") # the secret of service principal tenant_id=os.getenv("SQL_TENANTID_62", "72f988bf-86f1-41af-91ab-2d7cd011db47") # tenant id of service principal print('------:',client_secret) sql_datastore = Datastore.register_azure_sql_database( workspace=ws, datastore_name=sql_datastore_name, server_name=server_name, database_name=database_name, client_id=client_id, client_secret=client_secret, tenant_id=tenant_id) print("registered sql databse datastore with name: %s" % sql_datastore_name)
ERROR - Registering datastore failed with 400 error code and error message
b'{\n "error": {\n "code": "UserError",\n "message": "Azure SQL Database Error. Please check the correctness of the datastore information.",\n "target": null,\n "details": [],\n "innerError": null,\n "debugInfo": {\n "type": "Microsoft.MachineLearning.Common.WebApi.Exceptions.BadRequestException",\n "message": "Azure SQL Database Error. Please check the correctness of the datastore information.",\n "stackTrace": " at Microsoft.MachineLearning.DataStore.Services.AzureStorageProvider.Exists(DataStoreDto dto, WorkspaceMetadata workspace, Boolean createIfNotExists) in /home/vsts/work/1/s/src/azureml-api/src/DataStore/Services/AzureStorageProvider.cs:line 81\n at Microsoft.MachineLearning.DataStore.Services.StorageService.SaveDataStore(WorkspaceMetadata workspace, DataStoreDto dto, Boolean createIfNotExists, Boolean skipValidation) in /home/vsts/work/1/s/src/azureml-api/src/DataStore/Services/StorageService.cs:line 173\n at Microsoft.MachineLearning.DataStore.EntryPoints.Controllers.DataStoreController.CreateOrUpdate(DataStoreDto dto, Boolean create, Boolean createIfNotExists, Boolean skipValidation) in /home/vsts/work/1/s/src/azureml-api/src/DataStore/EntryPoints/Controllers/DataStoreController.cs:line 202\n at Microsoft.MachineLearning.DataStore.EntryPoints.Controllers.DataStoreController.Create(DataStoreDto dto, Boolean createIfNotExists, Boolean skipValidation) in /home/vsts/work/1/s/src/azureml-api/src/DataStore/EntryPoints/Controllers/DataStoreController.cs:line 96\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()",\n "innerException": {\n "type": "System.Data.SqlClient.SqlException",\n "message": "Login failed for user 'NT AUTHORITY\\ANONYMOUS LOGON'.",\n "stackTrace": " at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)\n at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\n at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)\n at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\n at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\n at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\n at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)\\n at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry)\n at System.Data.SqlClient.SqlConnection.Open()\n at Microsoft.MachineLearning.DataStore.Services.AzureStorageProvider.SqlDatabaseExists(DataStoreDto dto) in /home/vsts/work/1/s/src/azureml-api/src/DataStore/Services/AzureStorageProvider.Sql.cs:line 49",\n "innerException": null,\n "data": {\n "HelpLink.ProdName": "Microsoft SQL Server",\n "HelpLink.EvtSrc": "MSSQLServer",\n "HelpLink.EvtID": "18456",\n "HelpLink.BaseHelpUrl": "http://go.microsoft.com/fwlink",\n "HelpLink.LinkId": "20476"\n },\n "errorResponse": null\n },\n "data": {},\n "errorResponse": null\n }\n },\n "correlation": {\n "operation": "3c23db01d64adc42bb19f11afaa9aa99",\n "request": "7ta+RqIHZtA="\n },\n "environment": "westeurope",\n "location": "westeurope",\n "time": "2019-08-12T10:00:04.5194504+00:00"\n}'
HttpOperationError Traceback (most recent call last)
c:\anaconda\envs\mlservice2\lib\site-packages\azureml\core\datastore.py in register_azure_sql_database(workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite) 300 return Datastore._client().register_azure_sql_database( 301 workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, --> 302 resource_url, authority_url, endpoint, overwrite) 303 304 @ staticmethod
c:\anaconda\envs\mlservice2\lib\site-packages\azureml\data\datastore_client.py in register_azure_sql_database(workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite) 241 return _DatastoreClient._register_azure_sql_database( 242 workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, --> 243 resource_url, authority_url, endpoint, overwrite) 244 245 @staticmethod
c:\anaconda\envs\mlservice2\lib\site-packages\azureml\data\datastore_client.py in _register_azure_sql_database(ws, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite, auth, host) 415 module_logger.debug("Converted data into DTO") 416 return _DatastoreClient._register(ws=ws, dto=datastore, create_if_not_exists=False, skip_validation=False, --> 417 overwrite=overwrite, auth=auth, host=host) 418 419 @staticmethod
c:\anaconda\envs\mlservice2\lib\site-packages\azureml\data\datastore_client.py in _register(ws, dto, create_if_not_exists, skip_validation, overwrite, auth, host) 455 module_logger.error("Registering datastore failed with {} error code and error message\n{}" 456 .format(e.response.status_code, e.response.content)) --> 457 raise e 458 459 return _DatastoreClient._get(ws, dto.name, auth, host)
c:\anaconda\envs\mlservice2\lib\site-packages\azureml\data\datastore_client.py in _register(ws, dto, create_if_not_exists, skip_validation, overwrite, auth, host) 445 module_logger.debug("Posting DTO to datastore service") 446 client.data_store.create(ws._subscription_id, ws._resource_group, ws._workspace_name, --> 447 dto, create_if_not_exists, skip_validation) 448 except HttpOperationError as e: 449 if e.response.status_code == 400 and overwrite:
c:\anaconda\envs\mlservice2\lib\site-packages\azureml_restclient\operations\data_store_operations.py in create(self, subscription_id, resource_group_name, workspace_name, dto, create_if_not_exists, skip_validation, custom_headers, raw, **operation_config) 165 166 if response.status_code not in [200]: --> 167 raise HttpOperationError(self._deserialize, response) 168 169 if raw:
HttpOperationError: Operation returned an invalid status code 'Azure SQL Database Error. Please check the correctness of the datastore information.'
Provide the following if applicable:
- Your Python & SDK version AML Service: SDK version: 1.0.41
- Python Scripts or the full notebook name aml-pipelines-data-transfer
- Pipeline definition
- Environment definition
- Example data
- Any log files.
- Run and Workspace Id
To Reproduce Steps to reproduce the behavior: 1.
Expected behavior A clear and concise description of what you expected to happen.
Additional context I think the main error is: "type": "System.Data.SqlClient.SqlException",\n "message": "Login failed for user 'NT AUTHORITY\\ANONYMOUS LOGON'.",\n
Can you please make sure you're following the steps mentioned here to give correct permissions to your service principal identity?
Hi, Now I have a new error:
ERROR - Registering datastore failed with a 400 error code and error message 'Error when parsing request; unable to deserialize request body'
ErrorResponseException Traceback (most recent call last)
C:\Anaconda\envs\pipeline\lib\site-packages\azureml\core\datastore.py in register_azure_sql_database(workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite) 323 return Datastore._client().register_azure_sql_database( 324 workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, --> 325 resource_url, authority_url, endpoint, overwrite) 326 327 @ staticmethod
C:\Anaconda\envs\pipeline\lib\site-packages\azureml\data\datastore_client.py in register_azure_sql_database(workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite) 381 return _DatastoreClient._register_azure_sql_database( 382 workspace, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, --> 383 resource_url, authority_url, endpoint, overwrite) 384 385 @staticmethod
C:\Anaconda\envs\pipeline\lib\site-packages\azureml\data\datastore_client.py in _register_azure_sql_database(ws, datastore_name, server_name, database_name, tenant_id, client_id, client_secret, resource_url, authority_url, endpoint, overwrite, auth, host) 562 module_logger.debug("Converted data into DTO") 563 return _DatastoreClient._register(ws=ws, dto=datastore, create_if_not_exists=False, skip_validation=False, --> 564 overwrite=overwrite, auth=auth, host=host) 565 566 @staticmethod
C:\Anaconda\envs\pipeline\lib\site-packages\azureml\data\datastore_client.py in _register(ws, dto, create_if_not_exists, skip_validation, overwrite, auth, host) 608 module_logger.error("Registering datastore failed with a {} error code and error message '{}'" 609 .format(e.response.status_code, _DatastoreClient._get_http_exception_message(e))) --> 610 raise e 611 612 return _DatastoreClient._get(ws, dto.name, auth, host)
C:\Anaconda\envs\pipeline\lib\site-packages\azureml\data\datastore_client.py in _register(ws, dto, create_if_not_exists, skip_validation, overwrite, auth, host) 596 client.data_stores.create(ws._subscription_id, ws._resource_group, ws._workspace_name, 597 dto, create_if_not_exists, skip_validation, --> 598 custom_headers=_DatastoreClient._custom_headers) 599 except HttpOperationError as e: 600 if e.response.status_code == 400 and overwrite and CONFLICT_MESSAGE in e.message:
C:\Anaconda\envs\pipeline\lib\site-packages\azureml_restclient\operations\data_stores_operations.py in create(self, subscription_id, resource_group_name, workspace_name, dto, create_if_not_exists, skip_validation, custom_headers, raw, **operation_config) 177 178 if response.status_code not in [200]: --> 179 raise models.ErrorResponseException(self._deserialize, response) 180 181 if raw:
ErrorResponseException: (UserError) Error when parsing request; unable to deserialize request body
@akshay-0 I'm ready to call this issue an error
The error is registering Azure SQL either through Python (notebook compute instance) or through the Azure ML Studio (new datastore).
I added my own email to the AAD Admin for Azure SQL -- and therefore was able to make the service principal a user for Azure SQL, and also added to the appropriate DB group.
Also: I have been able to use Azure Data Factory V2 to make linked datasets, with test connection successful. I have used the same information to login to azure with the service principal using azure-cli (local PowerShell).
Therefore: the issue is with Azure ML entirely. The error from both the notebook and studio environment is identical: "ERROR - Registering datastore failed with a 400 error code and error message 'Azure SQL Database Error. Please check the correctness of the datastore information.'"
@marktab Did you find out whether this error has been fixed? I am having an error trying to register a new datastore to connect Azure ML Studio to my Azure SQL DB.
AzureSqlError: Azure SQL Database Error -2146232060: Please check the correctness of the datastore information.
@YutongTie-MSFT should this ticket be open still?
@marktab If this error has been fixed we can go ahead to close it. Thanks.
@YutongTie-MSFT I believe you were correct to tag product team (which I am not)
@Farhad-Heybati have you solved the original question?
this is likely due to the permission of the service principal. you can also register sqldb with sql username and password as an alternative.