swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: The Azure SQL Database management API provides a RESTful set of web APIs that interact with Azure SQL Database services to manage your databases. The API enables users to create, retrieve, update, and delete databases, servers, and other entities.
  title: SqlManagementClient
  version: 2018-06-01-preview
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/sql/resource-manager/Microsoft.Sql/preview/2018-06-01-preview/managedDatabases.json
      version: "2.0"
  x-preferred: true
  x-providerName: azure.com
  x-serviceName: sql-managedDatabases
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
parameters:
  ApiVersionParameter:
    description: The API version to use for the request.
    in: query
    name: api-version
    required: true
    type: string
    x-ms-parameter-location: client
  BlobAuditingPolicyNameParameter:
    description: The name of the blob auditing policy.
    enum:
      - default
    in: path
    name: blobAuditingPolicyName
    required: true
    type: string
    x-ms-parameter-location: method
  DatabaseNameParameter:
    description: The name of the database.
    in: path
    name: databaseName
    required: true
    type: string
    x-ms-parameter-location: method
  ManagedInstanceNameParameter:
    description: The name of the managed instance.
    in: path
    name: managedInstanceName
    required: true
    type: string
    x-ms-parameter-location: method
  ResourceGroupParameter:
    description: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
    in: path
    name: resourceGroupName
    required: true
    type: string
    x-ms-parameter-location: method
  ServerNameParameter:
    description: The name of the server.
    in: path
    name: serverName
    required: true
    type: string
    x-ms-parameter-location: method
  SqlVirtualMachineContainerNameParameter:
    description: The name of the SqlVirtualMachineContainer.
    in: path
    name: sqlVirtualMachineContainerName
    required: true
    type: string
    x-ms-parameter-location: method
  SqlVirtualMachineInstanceNameParameter:
    description: The name of the SqlVirtualMachineInstance.
    in: path
    name: sqlVirtualMachineInstanceName
    required: true
    type: string
    x-ms-parameter-location: method
  SubscriptionIdParameter:
    description: The subscription ID that identifies an Azure subscription.
    in: path
    name: subscriptionId
    required: true
    type: string
    x-ms-parameter-location: client
  VirtualClusterNameParameter:
    description: The name of the virtual cluster.
    in: path
    name: virtualClusterName
    required: true
    type: string
    x-ms-parameter-location: method
paths:
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases":
    get:
      description: Gets a list of managed databases.
      operationId: ManagedDatabases_ListByInstance
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the list of databases.
          schema:
            $ref: "#/definitions/ManagedDatabaseListResult"
        default:
          description: |-
            *** Error Responses: ***

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.
      tags:
        - ManagedDatabases
      x-ms-examples:
        List databases by managed instances:
          parameters:
            api-version: 2015-05-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            resourceGroupName: Test1
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                value:
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/testdb1
                    location: southeastasia
                    name: testdb1
                    properties:
                      collation: SQL_Latin1_General_CP1_CI_AS
                      creationDate: 2017-08-04T15:00:17.73Z
                      defaultSecondaryLocation: North Europe
                      status: Online
                    type: Microsoft.Sql/managedInstances/databases
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/testdb2
                    location: southeastasia
                    name: testdb2
                    properties:
                      collation: SQL_Latin1_General_CP1_CI_AS
                      creationDate: 2017-08-04T15:00:17.73Z
                      defaultSecondaryLocation: North Europe
                      status: Online
                    type: Microsoft.Sql/managedInstances/databases
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}":
    delete:
      description: Deletes a managed database.
      operationId: ManagedDatabases_Delete
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully deleted the managed database.
        "202":
          description: Deleting the managed database is in progress.
        "204":
          description: The specified managed database does not exist.
        default:
          description: |-
            *** Error Responses: ***

             * 400 CannotMoveOrDropSyncMetadataDatabase - Cannot drop database used as sync metadata database.

             * 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

             * 400 CannotMoveOrDropJobAccountDatabase - Cannot drop database associated with job account.

             * 400 GeoReplicationDatabaseNotPrimary - The operation cannot be performed since the database '{0}' is a replication target.

             * 400 GeoReplicationDatabaseNotSecondary - The operation expects the database to be a replication target.

             * 400 ManagedInstanceUpdateSloInProgress - "The operation could not be completed because a service tier change is in progress for managed instance '{0}.' Please wait for the operation in progress to complete and try again."

             * 400 DropDisallowedDuringFailover - Can not drop database because a failover operation is in progress on the failover group.

             * 404 OperationIdNotFound - The operation with Id does not exist.

             * 404 ServerNotInSubscription - Specified server does not exist on the specified subscription.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 409 OperationCancelled - The operation has been cancelled by user.

             * 409 OperationInterrupted - The operation on the resource could not be completed because it was interrupted by another operation on the same resource.

             * 409 ServerDisabled - Server is disabled.

             * 429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.

             * 429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 500 OperationTimedOut - The operation timed out and automatically rolled back. Please retry the operation.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - ManagedDatabases
      x-ms-examples:
        Delete managed database:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: testdb
            managedInstanceName: managedInstance
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200": {}
            "202": {}
            "204": {}
      x-ms-long-running-operation: true
    get:
      description: Gets a managed database.
      operationId: ManagedDatabases_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the specified managed database.
          schema:
            $ref: "#/definitions/ManagedDatabase"
        default:
          description: |-
            *** Error Responses: ***

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 ResourceNotFound - The requested resource was not found.
      tags:
        - ManagedDatabases
      x-ms-examples:
        Gets a managed database:
          parameters:
            api-version: 2015-05-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            resourceGroupName: Test1
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/testdb1
                location: southeastasia
                name: testdb1
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-08-04T15:00:17.73Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                type: Microsoft.Sql/managedInstances/databases
    patch:
      description: Updates an existing database.
      operationId: ManagedDatabases_Update
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The requested database resource state.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/ManagedDatabaseUpdate"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the database.
          schema:
            $ref: "#/definitions/ManagedDatabase"
        "202":
          description: Updating the managed database is in progress.
        default:
          description: |-
            *** Error Responses: ***

             * 400 PitrPointInTimeInvalid - The point in time {0} is not valid. Valid point in time range from {1} days early to now and not before source server creation time.

             * 400 CannotUseTrailingWhitespacesInDatabaseName - The database name validation failed.

             * 400 InvalidBackupRetentionPeriod - The retention days of {0} is not a valid configuration. Valid backup retention in days must be between {1} and {2}

             * 400 ManagedDatabaseNameInUse - Database '{0}' already exists. Choose a different database name.

             * 400 NoMoreSpaceInManagedInstance - The managed instance has reached its storage limit. The storage usage for the managed instance cannot exceed (%d) MBs.

             * 400 ManagedInstanceUpdateSloInProgress - "The operation could not be completed because a service tier change is in progress for managed instance '{0}.' Please wait for the operation in progress to complete and try again."

             * 400 SourceDatabaseNotFound - The source database does not exist.

             * 400 RegionDoesNotSupportVersion - A user attempted to create a server of a specified version in a location where that server version isn't supported.

             * 400 PasswordNotComplex - The provided password is not complex enough.

             * 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

             * 400 SubscriptionNotFound - The requested subscription was not found.

             * 400 InvalidServerName - Invalid server name specified.

             * 400 SourceServerNotFound - The server part of a source database id provided in a CreateDatabaseAsCopy API call doesn't map to an existing server.

             * 400 TokenTooLong - The provided token is too long.

             * 400 CurrentDatabaseSizeExceedsMaxSize - User attempted to reduce the max size for a database to a size smaller than the current usage.

             * 400 InvalidCollation - Collation is not recognized by the server.

             * 400 ServerNotFound - The requested server was not found.

             * 400 UnsupportedServiceName - The specified name is an invalid name because it contains one or more unsupported unicode characters.

             * 400 CurrentDatabaseLogSizeExceedsMaxSize - User attempted to change the database to a sku with lower max log size than the current usage.

             * 400 DatabaseNumberLimitReached - Maximum number of databases for SQL Database Managed Instance reached.

             * 400 InvalidDatabaseCreateOrUpdateRequest - The request body for the create or update database operation is invalid.

             * 400 InvalidResourceId - Invalid resource identifier.

             * 400 InvalidSourceDatabaseId - Invalid source database identifier.

             * 400 InvalidRestorableDroppedDatabaseId - Invalid restorable dropped database identifier

             * 400 MismatchingResourceGroupNameWithUrl - The provided resource group name did not match the name in the Url.

             * 400 MismatchingServerNameWithUrl - The provided server name did not match the name in the Url.

             * 400 MismatchingSubscriptionWithUrl - The provided subscription did not match the subscription in the Url.

             * 400 MissingCollation - Collation is required.

             * 400 MissingSourceDatabaseId - Missing source database identifier.

             * 400 MissingRestorePointInTime - Missing restore point in time

             * 400 MissingStorageContainerSasToken - Missing storage container SAS token

             * 400 MissingStorageContainerUri - Missing storage container URI

             * 400 RestorableDroppedDatabaseIdGivenForRestoreWithSourceDatabaseId - Cannot specify restorableDroppedDatabaseId when sourceDatabaseId is already given in restore create mode

             * 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 ResourceNotFound - The requested resource was not found.

             * 404 CannotFindServerCertificateWithThumbprint - Cannot find server certificate with thumbprint '{0}'. Please use PowerShell Cmdlet 'Add-AzureRmSqlManagedInstanceTransparentDataEncryptionCertificate' to create the certificate.

             * 404 CannotFindObject - Cannot find the object because it does not exist or you do not have permissions

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ServerNotInSubscription - Specified server does not exist on the specified subscription.

             * 404 RestoreSourceDatabaseNotFound - Could not find database '{0}' at time '{1}' that can be restored.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 409 RemoteDatabaseExists - The destination database name already exists on the destination server.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 409 SubscriptionDisabled - Subscription is disabled.

             * 409 ManagementServiceDatabaseBusy - Database '{0}' is busy with another operation. Please try your operation later.

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.

             * 429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 500 ActivateOrDeactivateWorkflowThrottling - Activation or deactivation workflow failed because there are too many concurrent workflows

             * 503 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - ManagedDatabases
      x-ms-examples:
        Updates a managed database with maximal properties:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: testdb
            managedInstanceName: managedInstance
            parameters:
              tags:
                tagKey1: TagValue1
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb
                location: southeastasia
                name: testdb
                tags:
                  tagKey1: TagValue1
              properties:
                collation: SQL_Latin1_General_CP1_CI_AS
                creationDate: 2017-06-07T04:41:33.937Z
                defaultSecondaryLocation: North Europe
                status: Online
                type: Microsoft.Sql/servers/databases
            "202": {}
        Updates a managed database with minimal properties:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: testdb
            managedInstanceName: managedInstance
            parameters:
              tags:
                tagKey1: TagValue1
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb
                location: southeastasia
                name: testdb
                tags:
                  tagKey1: TagValue1
              properties:
                collation: SQL_Latin1_General_CP1_CI_AS
                creationDate: 2017-06-07T04:41:33.937Z
                defaultSecondaryLocation: North Europe
                status: Online
                type: Microsoft.Sql/servers/databases
            "202": {}
      x-ms-long-running-operation: true
    put:
      description: Creates a new database or updates an existing database.
      operationId: ManagedDatabases_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The requested database resource state.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/ManagedDatabase"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the database.
          schema:
            $ref: "#/definitions/ManagedDatabase"
        "201":
          description: Successfully created the database.
          schema:
            $ref: "#/definitions/ManagedDatabase"
        "202":
          description: Accepted
        default:
          description: |-
            *** Error Responses: ***

             * 400 PitrPointInTimeInvalid - The point in time {0} is not valid. Valid point in time range from {1} days early to now and not before source server creation time.

             * 400 CannotUseTrailingWhitespacesInDatabaseName - The database name validation failed.

             * 400 InvalidBackupRetentionPeriod - The retention days of {0} is not a valid configuration. Valid backup retention in days must be between {1} and {2}

             * 400 ManagedDatabaseNameInUse - Database '{0}' already exists. Choose a different database name.

             * 400 NoMoreSpaceInManagedInstance - The managed instance has reached its storage limit. The storage usage for the managed instance cannot exceed (%d) MBs.

             * 400 ManagedInstanceUpdateSloInProgress - "The operation could not be completed because a service tier change is in progress for managed instance '{0}.' Please wait for the operation in progress to complete and try again."

             * 400 SourceDatabaseNotFound - The source database does not exist.

             * 400 RegionDoesNotSupportVersion - A user attempted to create a server of a specified version in a location where that server version isn't supported.

             * 400 PasswordNotComplex - The provided password is not complex enough.

             * 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

             * 400 SubscriptionNotFound - The requested subscription was not found.

             * 400 InvalidServerName - Invalid server name specified.

             * 400 SourceServerNotFound - The server part of a source database id provided in a CreateDatabaseAsCopy API call doesn't map to an existing server.

             * 400 TokenTooLong - The provided token is too long.

             * 400 CurrentDatabaseSizeExceedsMaxSize - User attempted to reduce the max size for a database to a size smaller than the current usage.

             * 400 InvalidCollation - Collation is not recognized by the server.

             * 400 ServerNotFound - The requested server was not found.

             * 400 UnsupportedServiceName - The specified name is an invalid name because it contains one or more unsupported unicode characters.

             * 400 CurrentDatabaseLogSizeExceedsMaxSize - User attempted to change the database to a sku with lower max log size than the current usage.

             * 400 DatabaseNumberLimitReached - Maximum number of databases for SQL Database Managed Instance reached.

             * 400 InvalidDatabaseCreateOrUpdateRequest - The request body for the create or update database operation is invalid.

             * 400 InvalidResourceId - Invalid resource identifier.

             * 400 InvalidSourceDatabaseId - Invalid source database identifier.

             * 400 InvalidRestorableDroppedDatabaseId - Invalid restorable dropped database identifier

             * 400 MismatchingResourceGroupNameWithUrl - The provided resource group name did not match the name in the Url.

             * 400 MismatchingServerNameWithUrl - The provided server name did not match the name in the Url.

             * 400 MismatchingSubscriptionWithUrl - The provided subscription did not match the subscription in the Url.

             * 400 MissingCollation - Collation is required.

             * 400 MissingSourceDatabaseId - Missing source database identifier.

             * 400 MissingRestorePointInTime - Missing restore point in time

             * 400 MissingStorageContainerSasToken - Missing storage container SAS token

             * 400 MissingStorageContainerUri - Missing storage container URI

             * 400 RestorableDroppedDatabaseIdGivenForRestoreWithSourceDatabaseId - Cannot specify restorableDroppedDatabaseId when sourceDatabaseId is already given in restore create mode

             * 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 ResourceNotFound - The requested resource was not found.

             * 404 CannotFindServerCertificateWithThumbprint - Cannot find server certificate with thumbprint '{0}'. Please use PowerShell Cmdlet 'Add-AzureRmSqlManagedInstanceTransparentDataEncryptionCertificate' to create the certificate.

             * 404 CannotFindObject - Cannot find the object because it does not exist or you do not have permissions

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ServerNotInSubscription - Specified server does not exist on the specified subscription.

             * 404 RestoreSourceDatabaseNotFound - Could not find database '{0}' at time '{1}' that can be restored.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 409 RemoteDatabaseExists - The destination database name already exists on the destination server.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 409 SubscriptionDisabled - Subscription is disabled.

             * 409 ManagementServiceDatabaseBusy - Database '{0}' is busy with another operation. Please try your operation later.

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.

             * 429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 500 ActivateOrDeactivateWorkflowThrottling - Activation or deactivation workflow failed because there are too many concurrent workflows

             * 503 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - ManagedDatabases
      x-ms-examples:
        Creates a new managed database by restoring from an external backup:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            parameters:
              location: southeastasia
              properties:
                collation: SQL_Latin1_General_CP1_CI_AS
                createMode: RestoreExternalBackup
                storageContainerSasToken: sv=2015-12-11&sr=c&sp=rl&sig=1234
                storageContainerUri: https://myaccountname.blob.core.windows.net/backups
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb1
                location: southeastasia
                name: testdb1
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb2
                location: southeastasia
                name: testdb2
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "202": {}
        Creates a new managed database from restoring a geo-replicated backup:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: testdb_recovered
            managedInstanceName: server1
            parameters:
              location: southeastasia
              properties:
                createMode: Recovery
                recoverableDatabaseId: /subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/server1/recoverableDatabases/testdb_recovered
                location: southeastasia
                name: testdb_recovered
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2018-11-07T04:41:33.937Z
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/managedInstances/databases
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb_recovered
                location: southeastasia
                name: testdb_recovered
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2018-11-07T04:41:33.937Z
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/managedInstances/databases
            "202": {}
        Creates a new managed database using point in time restore:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            parameters:
              location: southeastasia
              properties:
                createMode: PointInTimeRestore
                restorePointInTime: 2017-07-14T05:35:31.503Z
                sourceDatabaseId: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb1
                location: southeastasia
                name: testdb1
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb2
                location: southeastasia
                name: testdb2
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "202": {}
        Creates a new managed database with maximal properties:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            parameters:
              location: southeastasia
              tags:
                tagKey1: TagValue1
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb1
                location: southeastasia
                name: testdb1
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb2
                location: southeastasia
                name: testdb2
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                tags:
                  tagKey1: TagValue1
                type: Microsoft.Sql/servers/databases
            "202": {}
        Creates a new managed database with minimal properties:
          parameters:
            api-version: 2017-03-01-preview
            databaseName: managedDatabase
            managedInstanceName: managedInstance
            parameters:
              location: southeastasia
            resourceGroupName: Default-SQL-SouthEastAsia
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb1
                location: southeastasia
                name: testdb1
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                type: Microsoft.Sql/servers/databases
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb2
                location: southeastasia
                name: testdb2
                properties:
                  collation: SQL_Latin1_General_CP1_CI_AS
                  creationDate: 2017-06-07T04:41:33.937Z
                  defaultSecondaryLocation: North Europe
                  status: Online
                type: Microsoft.Sql/servers/databases
            "202": {}
      x-ms-long-running-operation: true
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/completeRestore":
    post:
      description: Completes the restore operation on a managed database.
      operationId: ManagedDatabases_CompleteRestore
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The definition for completing the restore of this managed database.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/CompleteDatabaseRestoreDefinition"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully completed restore request.
        "202":
          description: Completing restore request is in progress.
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidDatabaseCompleteRestoreRequest - The complete database restore request is invalid

             * 400 InvalidDatabaseCompleteRestoreRequestLastBackupName - The last backup name is invalid

             * 400 InvalidIdentifier - The identifier contains NULL or an invalid unicode character.

             * 400 SourceDatabaseNotFound - The source database does not exist.

             * 400 TokenTooLong - The provided token is too long.

             * 400 UnsupportedServiceName - The specified name is an invalid name because it contains one or more unsupported unicode characters.

             * 400 MissingThumbprint - Can not find server certificate.

             * 400 PartiallyContainedDatabaseUnsupported - "Backup for a partially contained database is not supported."

             * 400 RequiredBackupIsNotLastRestored - Migration cannot be completed because provided backup file name is not the name of the last backup file that is restored.

             * 400 IncompatiblePhysicalLayoutTooFewDataFiles - Database backup contains incompatible physical layout. No data files are found in the backup.

             * 400 IncompatiblePhysicalLayoutNonOnlineDataFilesExist - Database backup contains incompatible physical layout. Non-online data files exist.

             * 400 IncompatiblePhysicalLayoutWrongNumberOfLogFiles - Database backup contains incompatible physical layout. Multiple log files are not supported.

             * 400 IncompatiblePhysicalLayoutNonOnlineLogFilesExist - Database backup contains incompatible physical layout. Non-online log files exist.

             * 400 IncompatiblePhysicalLayoutTooManyNonDataLogFiles - Database backup contains incompatible physical layout. Too many non-data/log files.

             * 400 BackupSetNotFound - "No backups were found to restore the database. Please contact support to restore the database.

             * 400 ExternalBackupAlreadySignaledToComplete - The restore request has already been signaled to complete.

             * 400 FullBackupNotFound - Full backup can not be found.

             * 400 ExternalBackupRestoreHasNotBeenStarted - The restore request can only be completed once the restore has started.

             * 400 RestoreFromStripedBackupsNotEnabled - Restoring from striped backups is not supported.

             * 400 BrokenRestorePlanNoFullBackup - The restore plan is broken because there is no full backup.

             * 400 BrokenRestorePlanWrongLogBackupLSN - The restore plan is broken because firstLsn of current log backup is not <= lastLsn of next log backup.

             * 400 BrokenRestorePlanWrongDiffBackupLSN - The restore plan is broken because firstLsn of diff backup is not >= firstLsn of full backup.

             * 400 BrokenRestorePlanGapInLogBackups - The restore plan is broken because firstLsn of current log backup is not equal to lastLsn of prev log backup.

             * 400 XtpInitializedDuringRestore - Memory-optimized filegroup must be empty in order to be restored on General Purpose tier of SQL Database Managed Instance.

             * 400 ManagedInstanceStorageLimitHit - The managed instance has reached its storage limit.
      tags:
        - ManagedDatabases
      x-ms-examples:
        Completes a managed database external backup restore.:
          parameters:
            api-version: 2018-06-01-preview
            databaseName: myDatabase
            managedInstanceName: myManagedInstanceName
            parameters:
              lastBackupName: testdb1_log4
            resourceGroupName: myRG
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200": {}
            "202": {}
      x-ms-long-running-operation: true
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/restoreDetails/{restoreDetailsName}":
    get:
      description: Gets managed database restore details.
      operationId: ManagedDatabaseRestoreDetails_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The name of the restore details to retrieve.
          enum:
            - Default
          in: path
          name: restoreDetailsName
          required: true
          type: string
          x-ms-enum:
            modelAsString: true
            name: RestoreDetailsName
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved restore details.
          schema:
            $ref: "#/definitions/ManagedDatabaseRestoreDetailsResult"
        default:
          description: |-
            *** Error Responses: ***

             * 400 MissingThumbprint - Can not find server certificate.

             * 400 PartiallyContainedDatabaseUnsupported - "Backup for a partially contained database is not supported."

             * 400 RequiredBackupIsNotLastRestored - Migration cannot be completed because provided backup file name is not the name of the last backup file that is restored.

             * 400 IncompatiblePhysicalLayoutTooFewDataFiles - Database backup contains incompatible physical layout. No data files are found in the backup.

             * 400 IncompatiblePhysicalLayoutNonOnlineDataFilesExist - Database backup contains incompatible physical layout. Non-online data files exist.

             * 400 IncompatiblePhysicalLayoutWrongNumberOfLogFiles - Database backup contains incompatible physical layout. Multiple log files are not supported.

             * 400 IncompatiblePhysicalLayoutNonOnlineLogFilesExist - Database backup contains incompatible physical layout. Non-online log files exist.

             * 400 IncompatiblePhysicalLayoutTooManyNonDataLogFiles - Database backup contains incompatible physical layout. Too many non-data/log files.

             * 400 BackupSetNotFound - "No backups were found to restore the database. Please contact support to restore the database.

             * 400 ExternalBackupAlreadySignaledToComplete - The restore request has already been signaled to complete.

             * 400 FullBackupNotFound - Full backup can not be found.

             * 400 ExternalBackupRestoreHasNotBeenStarted - The restore request can only be completed once the restore has started.

             * 400 RestoreFromStripedBackupsNotEnabled - Restoring from striped backups is not supported.

             * 400 BrokenRestorePlanNoFullBackup - The restore plan is broken because there is no full backup.

             * 400 BrokenRestorePlanWrongLogBackupLSN - The restore plan is broken because firstLsn of current log backup is not <= lastLsn of next log backup.

             * 400 BrokenRestorePlanWrongDiffBackupLSN - The restore plan is broken because firstLsn of diff backup is not >= firstLsn of full backup.

             * 400 BrokenRestorePlanGapInLogBackups - The restore plan is broken because firstLsn of current log backup is not equal to lastLsn of prev log backup.

             * 400 XtpInitializedDuringRestore - Memory-optimized filegroup must be empty in order to be restored on General Purpose tier of SQL Database Managed Instance.

             * 400 ManagedInstanceStorageLimitHit - The managed instance has reached its storage limit.

             * 400 ManagedDatabaseNotInRestoringState - Managed database is not in Restoring state.
      tags:
        - ManagedDatabaseRestoreDetails
      x-ms-examples:
        Managed database restore details.:
          parameters:
            api-version: 2018-06-01-preview
            databaseName: testdb
            managedInstanceName: managedInstance
            parameters:
              tags:
                tagKey1: TagValue1
            resourceGroupName: Default-SQL-SouthEastAsia
            restoreDetailsName: Default
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/testdb/restoreDetails/current
                name: current
                properties:
                  currentRestoringFileName: full_0
                  lastUploadedFileName: log2_3
                  lastUploadedFileTime: 2018-06-15T11:38:33Z
                  numberOfFilesDetected: 26
                  percentCompleted: 0
                  status: Restoring
                  unrestorableFiles: []
                type: Microsoft.Sql/managedInstances/databases/restoreDetails
definitions:
  CompleteDatabaseRestoreDefinition:
    description: Contains the information necessary to perform a complete database restore operation.
    properties:
      lastBackupName:
        description: The last backup name to apply
        type: string
    required:
      - lastBackupName
    type: object
  ManagedDatabase:
    allOf:
      - $ref: "#/definitions/TrackedResource"
    description: A managed database resource.
    properties:
      properties:
        $ref: "#/definitions/ManagedDatabaseProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    required:
      - location
    type: object
  ManagedDatabaseListResult:
    description: A list of managed databases.
    properties:
      nextLink:
        description: Link to retrieve next page of results.
        readOnly: true
        type: string
      value:
        description: Array of results.
        items:
          $ref: "#/definitions/ManagedDatabase"
        readOnly: true
        type: array
    type: object
  ManagedDatabaseProperties:
    description: The managed database's properties.
    properties:
      catalogCollation:
        description: Collation of the metadata catalog.
        enum:
          - DATABASE_DEFAULT
          - SQL_Latin1_General_CP1_CI_AS
        type: string
        x-ms-enum:
          modelAsString: true
          name: CatalogCollationType
        x-ms-mutability:
          - read
          - create
      collation:
        description: Collation of the managed database.
        type: string
        x-ms-mutability:
          - read
          - create
      createMode:
        description: "Managed database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore."
        enum:
          - Default
          - RestoreExternalBackup
          - PointInTimeRestore
          - Recovery
        type: string
        x-ms-enum:
          modelAsString: true
          name: ManagedDatabaseCreateMode
        x-ms-mutability:
          - create
      creationDate:
        description: Creation date of the database.
        format: date-time
        readOnly: true
        type: string
      defaultSecondaryLocation:
        description: Geo paired region.
        readOnly: true
        type: string
      earliestRestorePoint:
        description: Earliest restore point in time for point in time restore.
        format: date-time
        readOnly: true
        type: string
      failoverGroupId:
        description: Instance Failover Group resource identifier that this managed database belongs to.
        readOnly: true
        type: string
      recoverableDatabaseId:
        description: The resource identifier of the recoverable database associated with create operation of this database.
        type: string
        x-ms-mutability:
          - create
      restorableDroppedDatabaseId:
        description: The restorable dropped database resource id to restore when creating this database.
        type: string
        x-ms-mutability:
          - create
      restorePointInTime:
        description: Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database.
        format: date-time
        type: string
        x-ms-mutability:
          - create
      sourceDatabaseId:
        description: The resource identifier of the source database associated with create operation of this database.
        type: string
        x-ms-mutability:
          - create
      status:
        description: Status of the database.
        enum:
          - Online
          - Offline
          - Shutdown
          - Creating
          - Inaccessible
          - Restoring
          - Updating
        readOnly: true
        type: string
        x-ms-enum:
          modelAsString: true
          name: ManagedDatabaseStatus
      storageContainerSasToken:
        description: Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the storage container sas token.
        type: string
        x-ms-mutability:
          - create
      storageContainerUri:
        description: Conditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored.
        type: string
        x-ms-mutability:
          - create
    type: object
  ManagedDatabaseRestoreDetailsProperties:
    description: The managed database's restore details properties.
    properties:
      blockReason:
        description: The reason why restore is in Blocked state.
        readOnly: true
        type: string
      currentRestoringFileName:
        description: Current restoring file name.
        readOnly: true
        type: string
      lastRestoredFileName:
        description: Last restored file name.
        readOnly: true
        type: string
      lastRestoredFileTime:
        description: Last restored file time.
        format: date-time
        readOnly: true
        type: string
      lastUploadedFileName:
        description: Last uploaded file name.
        readOnly: true
        type: string
      lastUploadedFileTime:
        description: Last uploaded file time.
        format: date-time
        readOnly: true
        type: string
      numberOfFilesDetected:
        description: Number of files detected.
        format: int64
        readOnly: true
        type: integer
      percentCompleted:
        description: Percent completed.
        format: double
        readOnly: true
        type: number
      status:
        description: Restore status.
        readOnly: true
        type: string
      unrestorableFiles:
        description: List of unrestorable files.
        items:
          type: string
        readOnly: true
        type: array
    type: object
  ManagedDatabaseRestoreDetailsResult:
    allOf:
      - $ref: "#/definitions/ProxyResource"
    description: A managed database restore details.
    properties:
      properties:
        $ref: "#/definitions/ManagedDatabaseRestoreDetailsProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
  ManagedDatabaseUpdate:
    description: An managed database update.
    properties:
      properties:
        $ref: "#/definitions/ManagedDatabaseProperties"
        description: Resource properties.
        x-ms-client-flatten: true
      tags:
        additionalProperties:
          type: string
        description: Resource tags.
        type: object
    type: object
  ProxyResource:
    allOf:
      - $ref: "#/definitions/Resource"
    description: ARM proxy resource.
    properties: {}
    type: object
  Resource:
    description: ARM resource.
    properties:
      id:
        description: Resource ID.
        readOnly: true
        type: string
      name:
        description: Resource name.
        readOnly: true
        type: string
      type:
        description: Resource type.
        readOnly: true
        type: string
    type: object
    x-ms-azure-resource: true
  TrackedResource:
    allOf:
      - $ref: "#/definitions/Resource"
    description: ARM tracked top level resource.
    properties:
      location:
        description: Resource location.
        type: string
        x-ms-mutability:
          - read
          - create
      tags:
        additionalProperties:
          type: string
        description: Resource tags.
        type: object
    required:
      - location
    type: object
