New-AzSqlDatabaseExport with private link

Josh Fennessy 26 Reputation points
2020-10-21T15:30:43.44+00:00

I'm trying to write a powershell script to export a database to a a BACPAC from a server with Private Link configured (no public access) using the latest version of the Az module (4.8.0). I'm having a hard time understanding what parameter values I should be passing in based on teh documentation. Here is my current code:

$exportRequest = New-AzSqlDatabaseExport
-ResourceGroupName $resourceGroupName
-ServerName $databaseServerName
-DatabaseName $db
-StorageKeytype $StorageKeytype
-StorageKey $storageKeyType
-StorageUri $BacpacUri
-AdministratorLogin $databaseAdminUserName
-AdministratorLoginPassword $adminPassword `
-UseNetworkIsolation $true
-SqlServerResourceIdForPrivateLink "/subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/mdp-replicated-source-data-prod-rg/providers/Microsoft.Sql/servers/mdp-replicated-data-sql-prod-01"

The error message I'm getting is

New-AzSqlDatabaseExport : The specified resource 'https://management.centralus.control.database.windows.net/modules/AzureResourceManager/subscriptions/xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/mdp-replicated-source-data-prod-rg/providers/Microsoft.Sql/servers/mdp-replicated-data-sql-p
rod-01/databases/[dbname]/export?api-version=2020-02-02-preview' was not found.

Does anyone have any good working examples of how to export a database from a server with Private Link using the latest verison of the Az modules?

UPDATE: I also tried to export this database to the same storage account via the Azure portal, and got a connectivity error to the database, so perhaps I don't have the right endpoints created to do the export operation? I'm having a hard time finding any documentation that helps describe what is required to export a database with Azure Private Link configured

UPDATE 2: If I re-enable the public endpoint (via the portal) and then request an export (via the portal) it works successfully. Do we need to enable public endpoint to do the export?

Azure SQL Database
Azure Private Link
Azure Private Link
An Azure service that provides private connectivity from a virtual network to Azure platform as a service, customer-owned, or Microsoft partner services.
461 questions
{count} votes

1 answer

Sort by: Most helpful
  1. TravisCragg-MSFT 5,676 Reputation points Microsoft Employee
    2020-10-24T00:31:19.357+00:00

    When you have the Private Endpoint and no Public Endpoint for your database, the request must come from within the Virtual Network or a connected Network. Requests from the portal will not work.

    You will need to run these commands from a VM inside the Virtual Network, or temporarily enable the public endpoint in order for this to be successful.