Edit

Share via


New-AzSqlDatabaseExport

Exports an Azure SQL Database as a .bacpac file to a storage account.

Syntax

Default (Default)

New-AzSqlDatabaseExport
    [-DatabaseName] <String>
    [-ServerName] <String>
    -StorageKeyType <StorageKeyType>
    -StorageKey <String>
    -StorageUri <Uri>
    -AdministratorLogin <String>
    -AdministratorLoginPassword <SecureString>
    [-AuthenticationType <AuthenticationType>]
    [-UseNetworkIsolation <Boolean>]
    [-StorageAccountResourceIdForPrivateLink <String>]
    [-SqlServerResourceIdForPrivateLink <String>]
    [-ResourceGroupName] <String>
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The New-AzSqlDatabaseExport cmdlet exports an Azure SQL Database as a .bacpac file to a storage account. The get export database status request may be sent to retrieve status information for this request. This cmdlet is also supported by the SQL Server Stretch Database service on Azure.

Important

In order to make use of this cmdlet the firewall on the Azure SQL Server will need to be configured to "Allow Azure services and resources to access this server". If this is not configured then GatewayTimeout errors will be experienced. This is not required if a Private Link connection is established via the UseNetworkIsolation parameter.

Examples

Example 1: Create an export request for a database

New-AzSqlDatabaseExport -ResourceGroupName "RG01" -ServerName "Server01" -DatabaseName "Database01" -StorageKeyType "StorageAccessKey" -StorageKey "StorageKey01" -StorageUri "http://account01.blob.core.contoso.net/bacpacs/database01.bacpac" -AdministratorLogin "User" -AdministratorLoginPassword "secure password"
ResourceGroupName          : RG01
ServerName                 : Server01
DatabaseName               : Database01
StorageKeyType             : StorageAccessKey
StorageKey                 :
StorageUri                 : http://account01.blob.core.contoso.net/bacpacs/database01.bacpac
AdministratorLogin         : User
AdministratorLoginPassword :
AuthenticationType         : None
OperationStatusLink        : https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource01/providers/Microsoft.Sql/servers/server01/databases/database01/importExportOperationResults/00000000-00
                             0-0000-0000-000000000000?api-version=2014-04-01
Status                     : InProgress
ErrorMessage               :

This command creates an export request for the specified database.

$sqlServerName = "Server01"
$storageAccountName = "storageaccount1"
$subscriptionId = "00000000-0000-0000-0000-000000000000"
$resourceGroup = "RG01"
$managedIdentityResourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-managed-identity"
$pw = ConvertTo-SecureString "******" -AsPlainText -Force
New-AzSqlDatabaseExport `
    -ResourceGroupName $resourceGroup `
    -ServerName $sqlServerName `
    -DatabaseName "Database01" `
    -StorageKeyType ManagedIdentity `
    -StorageKey $managedIdentityResourceId `
    -StorageUri "https://storageaccount1.blob.core.windows.net/container1/my-file-name.bacpac" `
    -AuthenticationType ManagedIdentity `
    -AdministratorLogin $managedIdentityResourceId `
    -AdministratorLoginPassword $pw `
    -UseNetworkIsolation $true `
    -SqlServerResourceIdForPrivateLink "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Sql/servers/$sqlServerName" `
    -StorageAccountResourceIdForPrivateLink "/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Storage/storageAccounts/$storageAccountName"

This command creates an export request for the specified database using managed identity for authentication with connectivity over Private Link.

Parameters

-AdministratorLogin

Specifies the name of the SQL administrator.

If -AuthenticationType ManagedIdentity is provided, this should be the full resource ID of a user-assigned managed identity that is a Microsoft Entra administrator of the server.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AdministratorLoginPassword

Specifies the password of the SQL administrator.

Parameter properties

Type:SecureString
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-AuthenticationType

Specifies the type of authentication used to access the server. The default value is SQL if no authentication type is set. The acceptable values for this parameter are:

  • Sql. SQL authentication. Set the AdministratorLogin and AdministratorLoginPassword to the SQL administrator username and password.
  • ADPassword. Microsoft Entra authentication. Set AdministratorLogin and AdministratorLoginPassword to the Microsoft Entra administrator username and password. This parameter is only available on SQL Database V12 servers.
  • ManagedIdentity. Managed identity authentication. Use a user-assigned managed identity to authenticate with the SQL server. The managed identity must be a Microsoft Entra administrator for the server.

Parameter properties

Type:AuthenticationType
Default value:None
Accepted values:None, Sql, AdPassword, ManagedIdentity
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DatabaseName

Specifies the name of the SQL Database.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:2
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ResourceGroupName

Specifies the name of the resource group for the SQL Database server.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServerName

Specifies the name of the SQL Database server.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

The sql server resource id to create private link

Type:String
Default value:None
Supports wildcards:False
DontShow:False
(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

The storage account resource id to create private link

Type:String
Default value:None
Supports wildcards:False
DontShow:False
(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageKey

Specifies the access key for the storage account.

When -StorageKeyType ManagedIdentity is provided, this should be the full resource ID of a user-assigned managed identity which has write access on the storage account for the StorageUri provided (for example via a Storage Blob Data Contributor role assignment).

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageKeyType

Specifies the type of access key for the storage account. The acceptable values for this parameter are:

  • StorageAccessKey. This value uses a storage account key.
  • SharedAccessKey. This value uses a Shared Access Signature (SAS) key.
  • ManagedIdentity. Use a user-assigned managed identity for authentication with the storage account.

Parameter properties

Type:StorageKeyType
Default value:None
Accepted values:StorageAccessKey, SharedAccessKey, ManagedIdentity
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-StorageUri

The New-AzSqlDatabaseExport cmdlet exports an Azure SQL Database as a .bacpac file to a storage account. The get export database status request may be sent to retrieve status information for this request. This cmdlet is also supported by the SQL Server Stretch Database service on Azure.

Important

In order to make use of this cmdlet the firewall on the Azure SQL Server will need to be configured to "Allow Azure services and resources to access this server". If this is not configured then GatewayTimeout errors will be experienced. This is not required if a Private Link connection is established via the UseNetworkIsolation parameter.

Parameter properties

Type:Uri
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-UseNetworkIsolation

If set, will create private link for storage account and/or SQL server

Parameter properties

Type:Boolean
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

Outputs

AzureSqlDatabaseImportExportBaseModel

Notes

  • Keywords: azure, azurerm, arm, resource, management, manager, sql, database, mssql