Skip to content

feat(datamigration): add support for blob to Sql MI identity migrations #27738

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<copyright>Microsoft Corporation. All rights reserved.</copyright>
<tags>Azure ResourceManager ARM PSModule $(service-name)</tags>
<dependencies>
<dependency id="Az.Accounts" version="2.2.3" />
<dependency id="Az.Accounts" version="2.7.5" />
</dependencies>
</metadata>
<files>
Expand All @@ -23,9 +23,9 @@
<!-- https://github.com/NuGet/Home/issues/3584 -->
<file src="bin/Az.DataMigration.private.dll" target="bin" />
<file src="bin\Az.DataMigration.private.deps.json" target="bin" />
<file src="internal\**\*.*" exclude="internal\readme.md" target="internal" />
<file src="custom\**\*.*" exclude="custom\readme.md;custom\**\*.cs" target="custom" />
<file src="docs\**\*.md" exclude="docs\readme.md" target="docs" />
<file src="internal\**\*.*" exclude="internal\README.md" target="internal" />
<file src="custom\**\*.*" exclude="custom\README.md;custom\**\*.cs" target="custom" />
<file src="docs\**\*.md" exclude="docs\README.md" target="docs" />
<file src="exports\**\ProxyCmdletDefinitions.ps1" target="exports" />
<file src="utils\**\*.*" target="utils" />
</files>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the ""License"");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ""AS IS"" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
// is regenerated.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - DataMigration")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.14.10")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.14.10")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
34 changes: 32 additions & 2 deletions src/DataMigration/DataMigration.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ For information on how to develop for `Az.DataMigration`, see [how-to.md](how-to
> see https://aka.ms/autorest

``` yaml
commit: e8c359d8821038f133695c9b1f4cf40d330cbc80
commit: ff761e7c771e6e57442ade02e86a063ec9e7276c
require:
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
- $(repo)/specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/sqlmigration.json
- $(repo)/specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2025-03-15-preview/sqlmigration.json

title: DataMigration
module-version: 0.1.0
Expand Down Expand Up @@ -228,6 +228,12 @@ directive:
subject: ToSqlDb
parameter-name: PassThru
hide: true

- where:
verb: New
subject: ToSqlVM
parameter-name: AzureBlobAuthType|IdentityType|IdentityUserAssignedIdentity
hide: true

#Changing parameter names
- where:
Expand Down Expand Up @@ -271,6 +277,13 @@ directive:
parameter-name: TargetLocationAccountKey
set:
parameter-name: StorageAccountKey

- where:
verb: New
subject: ToSqlManagedInstance
parameter-name: IdentityType
set:
parameter-name: AzureBlobIdentityType

# Changing parameter description
- where:
Expand All @@ -284,6 +297,23 @@ directive:
- where:
verb: Set
remove: true

# Removed New-AzDataMigrationToSqlManagedInstance
# Replaced with a wrapper that renames IdentityUserAssignedIdentity to AzureBlobUserAssignedIdentity
# and changes its type from hashtable to string[] per managed identity guidelines
- where:
verb: New
subject: ToSqlManagedInstance
hide: true

# Remove Cosmos(Mongo) and MigrationService cmdlets
- where:
subject: \b\w*-?Mongo\w*\b
remove: true

- where:
subject: \b\w*-?MigrationService\w*\b
remove: true

# Formatting
- where:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "sqlMigrationServices",
"apiVersion": "2022-03-30-preview",
"apiVersion": "2025-03-15-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.datamigration"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Create a new database migration to a given SQL Managed Instance.
#>
function New-AzDataMigrationToSqlManagedInstance
{
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlMi')]
[CmdletBinding(PositionalBinding = $false, SupportsShouldProcess = $true)]
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Description('Create a new database migration to a given SQL Managed Instance.')]

param(
[Parameter(Mandatory, HelpMessage = "Name of the target SQL Managed Instance.")]
[string]${ManagedInstanceName},

[Parameter(Mandatory, HelpMessage = "Name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.")]
[string]${ResourceGroupName},

[Parameter(Mandatory, HelpMessage = "The name of the target database.")]
[string]${TargetDbName},

[Parameter(HelpMessage = "Subscription ID that identifies an Azure subscription.")]
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[string]$SubscriptionId = (Get-AzContext).Subscription.Id,

[Parameter(HelpMessage = "Storage Account Key.")]
[string]${AzureBlobAccountKey},

[Parameter(HelpMessage = "Authentication type used for accessing Azure Blob Storage.")]
[ValidateSet("AccountKey", "ManagedIdentity")]
[string]${AzureBlobAuthType},

[Parameter(HelpMessage = "Blob container name where backups are stored.")]
[string]${AzureBlobContainerName},

[Parameter(HelpMessage = "Type of managed service identity.")]
[ValidateSet("SystemAssigned", "UserAssigned")]
[string]${AzureBlobIdentityType},

[Parameter(HelpMessage = "Resource Id of the storage account where backups are stored.")]
[string]${AzureBlobStorageAccountResourceId},

[Parameter(HelpMessage = "Password for username to access file share location.")]
[SecureString]${FileSharePassword},

[Parameter(HelpMessage = "Location as SMB share or local drive where backups are placed.")]
[string]${FileSharePath},

[Parameter(HelpMessage = "Username to access the file share location for backups.")]
[string]${FileShareUsername},

[Parameter(HelpMessage = "The set of user assigned identities associated with the resource.")]
[string[]]${AzureBlobUserAssignedIdentity},

[Parameter(HelpMessage = "Resource type.")]
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Support.ResourceType]${Kind},

[Parameter(HelpMessage = "Resource Id of the Migration Service.")]
[string]${MigrationService},

[Parameter(HelpMessage = "Offline migration.")]
[switch]${Offline},

[Parameter(HelpMessage = "Last backup name for offline migration. This is optional for migrations from file share. If it is not provided, then the service will determine the last backup file name based on latest backup files present in file share.")]
[string]${OfflineConfigurationLastBackupName},

[Parameter(HelpMessage = "Resource Id of the target resource.")]
[string]${Scope},

[Parameter(HelpMessage = "Name of the source database.")]
[string]${SourceDatabaseName},

[Parameter(HelpMessage = "Authentication type.")]
[string]${SourceSqlConnectionAuthentication},

[Parameter(HelpMessage = "Data source.")]
[string]${SourceSqlConnectionDataSource},

[Parameter(HelpMessage = "Whether to encrypt connection or not.")]
[switch]${SourceSqlConnectionEncryptConnection},

[Parameter(HelpMessage = "Password to connect to source SQL.")]
[SecureString]${SourceSqlConnectionPassword},

[Parameter(HelpMessage = "Whether to trust server certificate or not.")]
[switch]${SourceSqlConnectionTrustServerCertificate},

[Parameter(HelpMessage = "User name to connect to source SQL.")]
[string]${SourceSqlConnectionUserName},

[Parameter(HelpMessage = "Storage Account Key.")]
[string]${StorageAccountKey},

[Parameter(HelpMessage = "Resource Id of the storage account copying backups.")]
[string]${StorageAccountResourceId},

[Parameter(HelpMessage = "Database collation to be used for the target database.")]
[string]${TargetDatabaseCollation},

[Parameter(HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")]
[Alias("AzureRMContext", "AzureCredential")]
[System.Management.Automation.PSObject]$DefaultProfile,

[Parameter(HelpMessage = "Run the command as a job")]
[switch]$AsJob,

[Parameter(HelpMessage = "Run the command asynchronously")]
[switch]$NoWait,

[Parameter(HelpMessage = "Returns true when the command succeeds")]
[switch]$PassThru
)

process {
if($PSBoundParameters.ContainsKey("AzureBlobUserAssignedIdentity"))
{
$IdentityUserAssignedIdentity = @{}
$identities = $PSBoundParameters["AzureBlobUserAssignedIdentity"]
foreach ($identity in $identities) {
$IdentityUserAssignedIdentity[$identity] = @{}
}
$PSBoundParameters["IdentityUserAssignedIdentity"] = $IdentityUserAssignedIdentity
$null = $PSBoundParameters.Remove("AzureBlobUserAssignedIdentity")
}

Az.DataMigration.Internal\New-AzDataMigrationToSqlManagedInstance @PSBoundParameters
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Module Name: Az.DataMigration
Module Guid: e23fee23-903d-423e-9275-f8763efede9d
Module Guid: 5b85d9ae-d85d-4da6-9dde-d80f726fa7f9
Download Help Link: https://learn.microsoft.com/powershell/module/az.datamigration
Help Version: 1.0.0.0
Locale: en-US
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.ISqlMigrationService
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.ISqlMigrationService

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IAuthenticationKeys
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IAuthenticationKeys

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IIntegrationRuntimeMonitoringData
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IIntegrationRuntimeMonitoringData

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigration
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigration

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlDb
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlDb

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlMi
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlMi

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlVM
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlVM

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.ISqlMigrationService
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.ISqlMigrationService

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IRegenAuthKeys
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IRegenAuthKeys

## NOTES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Accept wildcard characters: False
```

### -Scope
Resource Id of the target resource (SQL VM or SQL Managed Instance)
Resource Id of the target resource.

```yaml
Type: System.String
Expand Down Expand Up @@ -496,7 +496,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigrationSqlDb
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlDb

## NOTES

Expand Down
Loading