Database Operation Status (classic)

 

Updated: October 5, 2016

THIS TOPIC APPLIES TO: noSQL Server yesAzure SQL DatabaseyesAzure SQL Data Warehouse noParallel 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.

This command uses the classic deployment model. You should use the newer Resource Manager based REST API commands located here. For more information, see Azure Resource Manager vs. classic deployment: Understand deployment models and the state of your resources.

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.

MethodRequest URIHTTP Version
GEThttps://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations/{operationGuid}HTTP/1.1
GEThttps://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations?databaseName={databaseName}HTTP/1.1
GEThttps://management.core.windows.net:8443/{subscriptionId}/services/sqlservers/servers/{serverName}/databaseoperations?contentview=genericHTTP/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 HeaderDescription
x-ms-versionRequired. Specifies the version of the operation to use for this request. This header should be set to 2012-03-01.

Request Body

None.

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 HeaderDescription
x-ms-request-idA 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="http://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="http://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 NameDescription
NameThe name of the operation.
TypeThe type of the service resource; Microsoft.SqlAzure.DatabaseOperation.
StateThe state of the database operation.
SelfLinkThe URI identifier for this resource.
ParentLinkThe URI identifier for the parent of this resource (the server).
IdThe identifier for this resource.
StateIdThe identifier for the state of this resource.
SessionActivityIdThe identifier for the session activity.
DatabaseNameThe name of the database.
PercentCompleteThe percent complete for this operation.
ErrorCodeSpecifies an error code if an error occurs.
ErrorSpecifies a description of the error if an error occurs.
ErrorSeveritySpecifies the error severity level if an error occurs.
ErrorStateSpecifies the state of the error if an error occurs.
StartTimeSpecifies the start time of the operation.
LastModifyTimeSpecifies the last modify time of the operation.

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

Show: