Skip to content

Document using managed identity with New-AzSqlDatabaseExport #27881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

## Version 6.0.4
* Added server level action groups in enum of action groups to be able to be configured via auditing.
* Documented using managed identity with `New-AzSqlDatabaseExport`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the update of ChangeLog.md.


## Version 6.0.3
* Added Information message to `Set-AzSqlInstance` for migrating Azure Sql database with GeoDr links to Azure Sql Hyperscale Edition
Expand Down
54 changes: 53 additions & 1 deletion src/Sql/Sql/help/New-AzSqlDatabaseExport.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The get export database status request may be sent to retrieve status informatio
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.
> 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

Expand All @@ -55,11 +55,39 @@ ErrorMessage :

This command creates an export request for the specified database.

### Example 2: Create an export request for a database using managed identity for authentication over private link

```powershell
$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 "AdministratorPassword" -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](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql&tabs=azure-portal#set-microsoft-entra-admin) of the server.

```yaml
Type: System.String
Parameter Sets: (All)
Expand All @@ -75,6 +103,17 @@ Accept wildcard characters: False
### -AdministratorLoginPassword
Specifies the password of the SQL administrator.

This is mandatory. When using `-AuthenticationType ManagedIdentity` a dummy value must be provided, for example:

```
$administratorPassword = ConvertTo-SecureString "AdministratorPassword" -AsPlainText -Force

New-AzSqlDatabaseExport `
#...
-AdministratorLoginPassword $administratorPassword `
#...
```

```yaml
Type: System.Security.SecureString
Parameter Sets: (All)
Expand All @@ -98,6 +137,9 @@ Set the *AdministratorLogin* and *AdministratorLoginPassword* to the SQL adminis
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](https://learn.microsoft.com/en-us/azure/azure-sql/database/authentication-aad-configure?view=azuresql&tabs=azure-portal#set-microsoft-entra-admin) for the server.

```yaml
Type: Microsoft.Azure.Commands.Sql.ImportExport.Model.AuthenticationType
Expand Down Expand Up @@ -205,6 +247,8 @@ Accept wildcard characters: 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](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/storage#storage-blob-data-contributor) role assignment).

```yaml
Type: System.String
Parameter Sets: (All)
Expand All @@ -224,6 +268,8 @@ The acceptable values for this parameter are:
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.

```yaml
Type: Microsoft.Azure.Commands.Sql.ImportExport.Model.StorageKeyType
Expand All @@ -241,6 +287,12 @@ Accept wildcard characters: False
### -StorageUri
Specifies the blob link, as a URL, to the .bacpac file.

For example:

```
-StorageUri "https://your-storage-account.blob.core.windows.net/your-container/your-file-name.bacpac" `
```

```yaml
Type: System.Uri
Parameter Sets: (All)
Expand Down