Database Operation Status (classic)
THIS TOPIC APPLIES TO: SQL Server Azure SQL DatabaseAzure SQL Data Warehouse Parallel Data Warehouse
Gets the status of a specific operation on a database, all the operations (history) on a database, or all the operations on all databases on a server.
This functionality is equivalent to querying the sys.dm_operation_status table.
Important
The recommended REST commands to work with SQL Database are the Resource Manager based Azure SQL Database REST API. While there is no change to SQL Database, be aware that the classic deployment model command in this article is scheduled for deprecation on December 1, 2019. For a table providing links to the specific new commands you should use, see Operations for Azure SQL Databases.
Request
The Database Operation Status request must be specified as follows:
Replace {subscriptionId} with your subscription ID.
Replace {serverName} with the name of the server containing the database whose operation you want to query.
Replace {operationGuid} with the unique identifier (Guid) for the operation.
Replace {databaseName} with a database name to get the history of all operations on that database.
Method | Request URI | HTTP Version |
---|---|---|
GET | https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations/{operationGuid} | HTTP/1.1 |
GET | https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations?databaseName={databaseName} | HTTP/1.1 |
GET | https://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations?contentview=generic | HTTP/1.1 |
The third form lists all operations on all databases on a server.
URI Parameters
None.
Request Headers
The following table describes the required and optional request headers:
Request Header | Description |
---|---|
x-ms-version | Required. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01. |
Request Body
None.
Response
The response includes an HTTP status code, a set of response headers, and a response body.
Status Code
Response Headers
The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.
Response Header | Description |
---|---|
x-ms-request-id | A value that uniquely identifies a request made against the database management service. This request id is used for request tracking. If a failure occurs that requires the user to contact Microsoft Support, the request id should be provided to Microsoft to assist in tracking and resolving the failure for the request. |
Response Body
The following is an example response for the history of all operations on a database.
The response to get database operations by {operationGuid} will only have one <ServiceResource> entity instead of 3.
The response to get database operations for all databases on the server will have a <ServiceResource> entity for each database operation that took place on any database on the server.
<ServiceResources xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ServiceResource>
<Name>ALTER DATABASE</Name>
<Type>Microsoft.SqlAzure.DatabaseOperation</Type>
<State>COMPLETED</State>
<SelfLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/serverv1/databaseoperations/8a8ea9c6-50ed-47e9-bb75-83db67002add</SelfLink>
<ParentLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/serverv1</ParentLink>
<Id>8a8ea9c6-50ed-47e9-bb75-83db67002add</Id>
<StateId>2</StateId>
<SessionActivityId>b1040145-5cb9-4f4b-884b-8aca10051abf</SessionActivityId>
<DatabaseName>test2</DatabaseName>
<PercentComplete>100</PercentComplete>
<ErrorCode>0</ErrorCode>
<Error/>
<ErrorSeverity>0</ErrorSeverity>
<ErrorState>0</ErrorState>
<StartTime>2014-04-08T19:40:31.3700000</StartTime>
<LastModifyTime>2014-04-08T19:40:35.4630000</LastModifyTime>
</ServiceResource>
<ServiceResource>
<Name>ALTER DATABASE</Name>
<Type>Microsoft.SqlAzure.DatabaseOperation</Type>
<State>FAILED</State>
<SelfLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/serverv1/databaseoperations/13ff6d35-24d5-474e-af44-9c979b691193</SelfLink>
<ParentLink>https://management.core.windows.net/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/serverv1</ParentLink>
<Id>13ff6d35-24d5-474e-af44-9c979b691193</Id>
<StateId>3</StateId>
<SessionActivityId>8e099299-d2d6-4488-808c-969cfdeb6624</SessionActivityId>
<DatabaseName>test2</DatabaseName>
<PercentComplete>100</PercentComplete>
<ErrorCode>40619</ErrorCode>
<Error>The edition 'Web' does not support the database max size '2 GB'.</Error>
<ErrorSeverity>16</ErrorSeverity>
<ErrorState>0</ErrorState>
<StartTime>2014-04-08T19:44:20.8830000</StartTime>
<LastModifyTime>2014-04-08T19:44:37.1170000</LastModifyTime>
</ServiceResource>
The following is an example response for a database restore request.
<ServiceResources xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ServiceResource>
<Name>DATABASE RESTORE</Name>
<Type>Microsoft.SqlAzure.DatabaseOperation</Type>
<State>IN_PROGRESS</State>
<SelfLink>https://management.core.windows.net:8443/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/server1/databaseoperations/966bd28f-0b25-4f7f-a5ad-a04c52e5e04a</SelfLink>
<ParentLink>https://management.core.windows.net:8443/00000000-0000-0000-0001-000000000001/services/sqlservers/servers/server1</ParentLink>
<Id>966bd28f-0b25-4f7f-a5ad-a04c52e5e04a</Id>
<StateId>1</StateId>
<SessionActivityId>966bd28f-0b25-4f7f-a5ad-a04c52e5e04a</SessionActivityId>
<DatabaseName>AdventureWorksLT_1</DatabaseName>
<PercentComplete>50</PercentComplete>
<ErrorCode>0</ErrorCode>
<Error />
<ErrorSeverity>0</ErrorSeverity>
<ErrorState>0</ErrorState>
<StartTime>2015-03-02T17:42:46.1400000Z</StartTime>
<LastModifyTime>2015-03-02T17:42:46.3770000Z</LastModifyTime>
</ServiceResource>
</ServiceResources>
The following table describes the elements in the response body:
Element Name | Description |
---|---|
Name | The name of the operation. |
Type | The type of the service resource; Microsoft.SqlAzure.DatabaseOperation. |
State | The state of the database operation. |
SelfLink | The URI identifier for this resource. |
ParentLink | The URI identifier for the parent of this resource (the server). |
Id | The identifier for this resource. |
StateId | The identifier for the state of this resource. |
SessionActivityId | The identifier for the session activity. |
DatabaseName | The name of the database. |
PercentComplete | The percent complete for this operation. |
ErrorCode | Specifies an error code if an error occurs. |
Error | Specifies a description of the error if an error occurs. |
ErrorSeverity | Specifies the error severity level if an error occurs. |
ErrorState | Specifies the state of the error if an error occurs. |
StartTime | Specifies the start time of the operation. |
LastModifyTime | Specifies the last modify time of the operation. |
See Also
Recover an Azure SQL database using Geo-Restore with REST API
Restore an Azure SQL database using Point in Time Restore with REST API
Restore a deleted Azure SQL database with REST API
Common REST API Error Codes
Operations for Azure SQL Databases
Azure SQL Database
Azure SQL Database Cmdlets