I have not actually tried this (but it peaks my interest to later).
You will not be able to use
Restore-Database because it only reads native backup formats from SQL Server, not Azure SQL.
BACPAC file created from your backup of an Azure SQL database is in a data-tier format. Which in this format contains the schema and data for the database. In order to restore this to a local instance in PowerShell you will have to utilize the
DAC objects to do the
restore. Which if you are loading the
SQLPS module the
DAC assembly is loaded for you.
Basic examples that I find online seem to follow this format:
Add-Type -path "C:\Program Files (x86)\Microsoft SQL Server\<version>\DAC\bin\Microsoft.SqlServer.Dac.dll"
$restoredDatabaseName = 'NewDatabase'
$bacpacFile = "Your BACPAC file you downloaded"
$conn = "Data Source=Server;Initial Catalog=master;Connection Timeout=0;Integrated Security=True;"
$importBac = New-Object Microsoft.SqlServer.Dac.DacServices $conn
$loadBac = [Microsoft.SqlServer.Dac.BacPackage]::Load($bacpacFile)
Once I get something setup I will test the above myself, just to make sure.
The dbatools PowerShell module now includes commands around managing DacPac files. This can be utilized to perform export and publish operations.
Publish-DbaDacpac. I have not had chance to test this against an Azure SQL instance.