Skip to content

Commit 95c50ed

Browse files
Alexander NosovAlexander Nosov
authored andcommitted
Updated Arcee migration script
1 parent 9035c7e commit 95c50ed

File tree

3 files changed

+47
-16
lines changed

3 files changed

+47
-16
lines changed

samples/manage/azure-arc-enabled-sql-server/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Use the following steps to migrate your existing SQL Server - Azure Arc resource
1717
```console
1818
curl https://raw.githubusercontent.com/microsoft/sql-server-samples/master/samples/manage/azure-arc-enabled-sql-server/migrate-to-azure-arc-data.ps1 -o migrate-to-azure-arc-data.ps1
1919
```
20+
2021
3. Run the script.
2122

2223
```console

samples/manage/azure-arc-enabled-sql-server/migrate-to-azure-arc-data.ps1

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
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
2222
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+
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

3850
Write-Host "Namespace migration completed for SQL Server - Azure Arc resources."
39-

samples/manage/azure-hybrid-benefit/ahb-usage-in-subscription.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
# This scripts calculates the AHB usage by all the SQL resources in a specific subscription
2-
# based on the selected Azure Hybrid Benefit option
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+
# This script calculates the usage of different types of SQL Server licenses by the SQL resources
16+
# in the specific subscriptions.
17+
#
18+
# NOTE:
19+
# 1. The script requires a .csv file with the list of subscriptions. Use Export-Csv comlet to create the file.
20+
# 2. SQL Database resources that use the DTU based business model are excluded.
21+
#
322

423
# Set the subscription Id
524
$SubcriptionId = read-host -Prompt "Enter Subscription ID"

0 commit comments

Comments
 (0)