Skip to content

Commit 3564cb8

Browse files
gansachgansach
andauthored
feat(datamigration): add support for blob to Sql MI identity migrations (#27738)
Co-authored-by: gansach <[email protected]>
1 parent 75413df commit 3564cb8

File tree

41 files changed

+614
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+614
-202
lines changed

src/DataMigration/DataMigration.Autorest/Az.DataMigration.nuspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<copyright>Microsoft Corporation. All rights reserved.</copyright>
1414
<tags>Azure ResourceManager ARM PSModule $(service-name)</tags>
1515
<dependencies>
16-
<dependency id="Az.Accounts" version="2.2.3" />
16+
<dependency id="Az.Accounts" version="2.7.5" />
1717
</dependencies>
1818
</metadata>
1919
<files>
@@ -23,9 +23,9 @@
2323
<!-- https://github.com/NuGet/Home/issues/3584 -->
2424
<file src="bin/Az.DataMigration.private.dll" target="bin" />
2525
<file src="bin\Az.DataMigration.private.deps.json" target="bin" />
26-
<file src="internal\**\*.*" exclude="internal\readme.md" target="internal" />
27-
<file src="custom\**\*.*" exclude="custom\readme.md;custom\**\*.cs" target="custom" />
28-
<file src="docs\**\*.md" exclude="docs\readme.md" target="docs" />
26+
<file src="internal\**\*.*" exclude="internal\README.md" target="internal" />
27+
<file src="custom\**\*.*" exclude="custom\README.md;custom\**\*.cs" target="custom" />
28+
<file src="docs\**\*.md" exclude="docs\README.md" target="docs" />
2929
<file src="exports\**\ProxyCmdletDefinitions.ps1" target="exports" />
3030
<file src="utils\**\*.*" target="utils" />
3131
</files>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0 (the ""License"");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
// Unless required by applicable law or agreed to in writing, software
7+
// distributed under the License is distributed on an ""AS IS"" BASIS,
8+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
// See the License for the specific language governing permissions and
10+
// limitations under the License.
11+
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
12+
// is regenerated.
13+
14+
using System;
15+
using System.Reflection;
16+
using System.Runtime.CompilerServices;
17+
using System.Runtime.InteropServices;
18+
19+
[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
20+
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
21+
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
22+
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - DataMigration")]
23+
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.14.10")]
24+
[assembly: System.Reflection.AssemblyVersionAttribute("0.14.10")]
25+
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
26+
[assembly: System.CLSCompliantAttribute(false)]

src/DataMigration/DataMigration.Autorest/README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ For information on how to develop for `Az.DataMigration`, see [how-to.md](how-to
2727
> see https://aka.ms/autorest
2828
2929
``` yaml
30-
commit: e8c359d8821038f133695c9b1f4cf40d330cbc80
30+
commit: ff761e7c771e6e57442ade02e86a063ec9e7276c
3131
require:
3232
- $(this-folder)/../../readme.azure.noprofile.md
3333
input-file:
34-
- $(repo)/specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/sqlmigration.json
34+
- $(repo)/specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2025-03-15-preview/sqlmigration.json
3535

3636
title: DataMigration
3737
module-version: 0.1.0
@@ -228,6 +228,12 @@ directive:
228228
subject: ToSqlDb
229229
parameter-name: PassThru
230230
hide: true
231+
232+
- where:
233+
verb: New
234+
subject: ToSqlVM
235+
parameter-name: AzureBlobAuthType|IdentityType|IdentityUserAssignedIdentity
236+
hide: true
231237

232238
#Changing parameter names
233239
- where:
@@ -271,6 +277,13 @@ directive:
271277
parameter-name: TargetLocationAccountKey
272278
set:
273279
parameter-name: StorageAccountKey
280+
281+
- where:
282+
verb: New
283+
subject: ToSqlManagedInstance
284+
parameter-name: IdentityType
285+
set:
286+
parameter-name: AzureBlobIdentityType
274287

275288
# Changing parameter description
276289
- where:
@@ -284,6 +297,23 @@ directive:
284297
- where:
285298
verb: Set
286299
remove: true
300+
301+
# Removed New-AzDataMigrationToSqlManagedInstance
302+
# Replaced with a wrapper that renames IdentityUserAssignedIdentity to AzureBlobUserAssignedIdentity
303+
# and changes its type from hashtable to string[] per managed identity guidelines
304+
- where:
305+
verb: New
306+
subject: ToSqlManagedInstance
307+
hide: true
308+
309+
# Remove Cosmos(Mongo) and MigrationService cmdlets
310+
- where:
311+
subject: \b\w*-?Mongo\w*\b
312+
remove: true
313+
314+
- where:
315+
subject: \b\w*-?MigrationService\w*\b
316+
remove: true
287317

288318
# Formatting
289319
- where:

src/DataMigration/DataMigration.Autorest/UX/Microsoft.DataMigration/sqlMigrationServices.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"resourceType": "sqlMigrationServices",
3-
"apiVersion": "2022-03-30-preview",
3+
"apiVersion": "2025-03-15-preview",
44
"learnMore": {
55
"url": "https://learn.microsoft.com/powershell/module/az.datamigration"
66
},
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Create a new database migration to a given SQL Managed Instance.
18+
#>
19+
function New-AzDataMigrationToSqlManagedInstance
20+
{
21+
[OutputType('Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigrationSqlMi')]
22+
[CmdletBinding(PositionalBinding = $false, SupportsShouldProcess = $true)]
23+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Description('Create a new database migration to a given SQL Managed Instance.')]
24+
25+
param(
26+
[Parameter(Mandatory, HelpMessage = "Name of the target SQL Managed Instance.")]
27+
[string]${ManagedInstanceName},
28+
29+
[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.")]
30+
[string]${ResourceGroupName},
31+
32+
[Parameter(Mandatory, HelpMessage = "The name of the target database.")]
33+
[string]${TargetDbName},
34+
35+
[Parameter(HelpMessage = "Subscription ID that identifies an Azure subscription.")]
36+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
37+
[string]$SubscriptionId = (Get-AzContext).Subscription.Id,
38+
39+
[Parameter(HelpMessage = "Storage Account Key.")]
40+
[string]${AzureBlobAccountKey},
41+
42+
[Parameter(HelpMessage = "Authentication type used for accessing Azure Blob Storage.")]
43+
[ValidateSet("AccountKey", "ManagedIdentity")]
44+
[string]${AzureBlobAuthType},
45+
46+
[Parameter(HelpMessage = "Blob container name where backups are stored.")]
47+
[string]${AzureBlobContainerName},
48+
49+
[Parameter(HelpMessage = "Type of managed service identity.")]
50+
[ValidateSet("SystemAssigned", "UserAssigned")]
51+
[string]${AzureBlobIdentityType},
52+
53+
[Parameter(HelpMessage = "Resource Id of the storage account where backups are stored.")]
54+
[string]${AzureBlobStorageAccountResourceId},
55+
56+
[Parameter(HelpMessage = "Password for username to access file share location.")]
57+
[SecureString]${FileSharePassword},
58+
59+
[Parameter(HelpMessage = "Location as SMB share or local drive where backups are placed.")]
60+
[string]${FileSharePath},
61+
62+
[Parameter(HelpMessage = "Username to access the file share location for backups.")]
63+
[string]${FileShareUsername},
64+
65+
[Parameter(HelpMessage = "The set of user assigned identities associated with the resource.")]
66+
[string[]]${AzureBlobUserAssignedIdentity},
67+
68+
[Parameter(HelpMessage = "Resource type.")]
69+
[Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Support.ResourceType]${Kind},
70+
71+
[Parameter(HelpMessage = "Resource Id of the Migration Service.")]
72+
[string]${MigrationService},
73+
74+
[Parameter(HelpMessage = "Offline migration.")]
75+
[switch]${Offline},
76+
77+
[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.")]
78+
[string]${OfflineConfigurationLastBackupName},
79+
80+
[Parameter(HelpMessage = "Resource Id of the target resource.")]
81+
[string]${Scope},
82+
83+
[Parameter(HelpMessage = "Name of the source database.")]
84+
[string]${SourceDatabaseName},
85+
86+
[Parameter(HelpMessage = "Authentication type.")]
87+
[string]${SourceSqlConnectionAuthentication},
88+
89+
[Parameter(HelpMessage = "Data source.")]
90+
[string]${SourceSqlConnectionDataSource},
91+
92+
[Parameter(HelpMessage = "Whether to encrypt connection or not.")]
93+
[switch]${SourceSqlConnectionEncryptConnection},
94+
95+
[Parameter(HelpMessage = "Password to connect to source SQL.")]
96+
[SecureString]${SourceSqlConnectionPassword},
97+
98+
[Parameter(HelpMessage = "Whether to trust server certificate or not.")]
99+
[switch]${SourceSqlConnectionTrustServerCertificate},
100+
101+
[Parameter(HelpMessage = "User name to connect to source SQL.")]
102+
[string]${SourceSqlConnectionUserName},
103+
104+
[Parameter(HelpMessage = "Storage Account Key.")]
105+
[string]${StorageAccountKey},
106+
107+
[Parameter(HelpMessage = "Resource Id of the storage account copying backups.")]
108+
[string]${StorageAccountResourceId},
109+
110+
[Parameter(HelpMessage = "Database collation to be used for the target database.")]
111+
[string]${TargetDatabaseCollation},
112+
113+
[Parameter(HelpMessage = "The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.")]
114+
[Alias("AzureRMContext", "AzureCredential")]
115+
[System.Management.Automation.PSObject]$DefaultProfile,
116+
117+
[Parameter(HelpMessage = "Run the command as a job")]
118+
[switch]$AsJob,
119+
120+
[Parameter(HelpMessage = "Run the command asynchronously")]
121+
[switch]$NoWait,
122+
123+
[Parameter(HelpMessage = "Returns true when the command succeeds")]
124+
[switch]$PassThru
125+
)
126+
127+
process {
128+
if($PSBoundParameters.ContainsKey("AzureBlobUserAssignedIdentity"))
129+
{
130+
$IdentityUserAssignedIdentity = @{}
131+
$identities = $PSBoundParameters["AzureBlobUserAssignedIdentity"]
132+
foreach ($identity in $identities) {
133+
$IdentityUserAssignedIdentity[$identity] = @{}
134+
}
135+
$PSBoundParameters["IdentityUserAssignedIdentity"] = $IdentityUserAssignedIdentity
136+
$null = $PSBoundParameters.Remove("AzureBlobUserAssignedIdentity")
137+
}
138+
139+
Az.DataMigration.Internal\New-AzDataMigrationToSqlManagedInstance @PSBoundParameters
140+
}
141+
}

src/DataMigration/DataMigration.Autorest/docs/Az.DataMigration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Module Name: Az.DataMigration
3-
Module Guid: e23fee23-903d-423e-9275-f8763efede9d
3+
Module Guid: 5b85d9ae-d85d-4da6-9dde-d80f726fa7f9
44
Download Help Link: https://learn.microsoft.com/powershell/module/az.datamigration
55
Help Version: 1.0.0.0
66
Locale: en-US

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationSqlService.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
187187
188188
## OUTPUTS
189189
190-
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.ISqlMigrationService
190+
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.ISqlMigrationService
191191
192192
## NOTES
193193

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationSqlServiceAuthKey.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
153153
154154
## OUTPUTS
155155
156-
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IAuthenticationKeys
156+
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IAuthenticationKeys
157157
158158
## NOTES
159159

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationSqlServiceIntegrationRuntimeMetric.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
168168
169169
## OUTPUTS
170170
171-
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IIntegrationRuntimeMonitoringData
171+
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IIntegrationRuntimeMonitoringData
172172
173173
## NOTES
174174

src/DataMigration/DataMigration.Autorest/docs/Get-AzDataMigrationSqlServiceMigration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
123123
124124
## OUTPUTS
125125
126-
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20220330Preview.IDatabaseMigration
126+
### Microsoft.Azure.PowerShell.Cmdlets.DataMigration.Models.Api20250315Preview.IDatabaseMigration
127127
128128
## NOTES
129129

0 commit comments

Comments
 (0)