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.
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
13
# ---------------------------------------------------------------------------------
14
14
#
15
- # Sample script for migrating the existing SQL Server - Azure Arc resources from Microsoft.AzureData namespace to Microsoft.AzureArcData namespace
15
+ # Sample script for migrating the existing SQL Server - Azure Arc resources from Microsoft.AzureData namespace to Microsoft.AzureArcData namespace
16
16
# within a single Resource Group
17
17
#
18
18
19
19
$ResourceGroup = read-host - Prompt " Enter Resource Group Name"
20
20
21
21
$SqlArcResources = Get-AzResource - ExpandProperties - ResourceType Microsoft.AzureData/ sqlServerInstances - ResourceGroupName $ResourceGroup
22
22
foreach ($r in $SqlArcResources ) {
23
+ Write-Host (" Migrating resource: {0}" -f $r.Name )
24
+
25
+ if ( ! ($r.Properties.containerResourceId -match " Microsoft.HybridCompute/machines" ) ) {
26
+ $arcResource = Get-AzResource - ResourceType Microsoft.HybridCompute/ machines - Name $r.Properties.containerResourceId
27
+ if ($null -eq $arcResource ) {
28
+ Write-Warning (" Could not locate the Machine - Azure Arc resource associated with this SQL Server Instance. You should manually un-register and re-register this instance." )
29
+ continue
30
+ } else {
31
+ $r.Properties.containerResourceId = $arcResource.ResourceId
32
+ }
33
+ }
34
+
23
35
if ( $null -ne $r.Properties.tcpPorts ){
24
36
Write-Warning " The property `" tcpPorts`" has been renamed to `" tcpStaticPorts`" . The property name will be updated during resource migration."
25
37
$r.Properties | Add-Member - MemberType NoteProperty - Name " tcpStaticPorts" - Value $r.Properties.tcpPorts
@@ -36,4 +48,3 @@ foreach ($r in $SqlArcResources) {
36
48
}
37
49
38
50
Write-Host " Namespace migration completed for SQL Server - Azure Arc resources."
39
-
0 commit comments