|
| 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 | +# Sample script for migrating the existing SQL Server - Azure Arc resources from Microsoft.AzureData namespace to Microsoft.AzureArcData namespace |
| 16 | +# within a single Resource Group |
| 17 | +# |
| 18 | + |
| 19 | +$ResourceGroup=read-host -Prompt "Enter Resource Group Name" |
| 20 | + |
| 21 | +$SqlArcResources = Get-AzResource -ExpandProperties -ResourceType Microsoft.AzureData/sqlServerInstances -ResourceGroupName $ResourceGroup |
| 22 | +foreach ($r in $SqlArcResources) { |
| 23 | + if( $null -ne $r.Properties.tcpPorts ){ |
| 24 | + Write-Warning "The property `"tcpPorts`" has been renamed to `"tcpStaticPorts`". The property name will be updated during resource migration." |
| 25 | + $r.Properties | Add-Member -MemberType NoteProperty -Name "tcpStaticPorts" -Value $r.Properties.tcpPorts |
| 26 | + $r.Properties.psobject.properties.remove("tcpPorts") |
| 27 | + } |
| 28 | + |
| 29 | + if( $null -ne $r.Properties.createTime ){ |
| 30 | + Write-Warning "There is a known bug in the createTime property. This property will be removed during resource migration." |
| 31 | + $r.Properties.psobject.properties.remove("createTime") |
| 32 | + } |
| 33 | + |
| 34 | + New-AzResource -ResourceName $r.Name -Location $r.Location -Properties $r.Properties -ResourceGroupName $r.ResourceGroupName ` |
| 35 | + -ResourceType Microsoft.AzureArcData/sqlServerInstances -Force |
| 36 | +} |
| 37 | + |
| 38 | +Write-Host "Namespace migration completed for SQL Server - Azure Arc resources." |
| 39 | + |
0 commit comments