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.
1313# ---------------------------------------------------------------------------------
1414#
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
1616# within a single Resource Group
1717#
1818
1919$ResourceGroup = read-host - Prompt " Enter Resource Group Name"
2020
2121$SqlArcResources = Get-AzResource - ExpandProperties - ResourceType Microsoft.AzureData/ sqlServerInstances - ResourceGroupName $ResourceGroup
2222foreach ($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+
2335 if ( $null -ne $r.Properties.tcpPorts ){
2436 Write-Warning " The property `" tcpPorts`" has been renamed to `" tcpStaticPorts`" . The property name will be updated during resource migration."
2537 $r.Properties | Add-Member - MemberType NoteProperty - Name " tcpStaticPorts" - Value $r.Properties.tcpPorts
@@ -36,4 +48,3 @@ foreach ($r in $SqlArcResources) {
3648}
3749
3850Write-Host " Namespace migration completed for SQL Server - Azure Arc resources."
39-
0 commit comments