Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 2.58 KB

File metadata and controls

56 lines (42 loc) · 2.58 KB
title PowerShell: Import a BACPAC File to a New Database
description Azure PowerShell example script to import a BACPAC file into a database in SQL Database
author SudhirRaparla
ms.author nvraparl
ms.reviewer wiassaf, mathoma
ms.date 06/10/2025
ms.service azure-sql-database
ms.subservice backup-restore
ms.topic sample
ms.custom
load & move data
sqldbrb=1
devx-track-azurepowershell
ms.devlang powershell

Use PowerShell to import a BACPAC file into a database in SQL Database

[!INCLUDEappliesto-sqldb]

This Azure PowerShell script example imports a database from a BACPAC file into a new database in SQL Database.

[!INCLUDE quickstarts-free-trial-note] [!INCLUDE updated-for-az] [!INCLUDE cloud-shell-try-it.md]

If you choose to install and use PowerShell locally, this tutorial requires Az PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.

Sample script

[!code-powershell-interactivemain]

Clean up deployment

Use the following command to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

Script explanation

This script uses the following commands. Each command in the table links to command-specific documentation.

Command Notes
New-AzResourceGroup Creates a resource group in which all resources are stored.
New-AzSqlServer Creates a server that hosts databases and elastic pools.
New-AzSqlServerFirewallRule Creates a server-level firewall rule for a server.
New-AzSqlDatabaseImport Imports a BACPAC file and create a new database on the server.
Remove-AzResourceGroup Deletes a resource group including all nested resources.

Related content