Azure Windows2012升级2016

Azure Windows2012升级2016

在 Windows 上安装 Azure PowerShell官方文档:

https://learn.microsoft.com/zh-cn/powershell/azure/install-azps-windows?view=azps-11.6.0\&viewFallbackFrom=azps-11.1.0\&tabs=windowspowershell\&pivots=windows-psgallery
Azure 中运行 Windows Server 的 VM 的就地升级官方文档:

https://docs.azure.cn/zh-cn/virtual-machines/windows-in-place-upgrade

在自己电脑配置Azure PowerShell

前置条件

从 PowerShell 运行以下命令以确定 PowerShell 版本

python 复制代码
$PSVersionTable.PSVersion

确定是否安装了 AzureRM PowerShell 模块

python 复制代码
Get-Module -Name AzureRM -ListAvailable

以提升为管理员的权限启动 Windows PowerShell 5.1,并运行以下命令以更新 PowerShellGet:

python 复制代码
Install-Module -Name PowerShellGet -Force

将 PowerShell 执行策略设置为"远程签名"或"更低限制"

python 复制代码
Get-ExecutionPolicy -List

将 PowerShell 执行策略设置为远程签名:

python 复制代码
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

安装 Az PowerShell 模块

python 复制代码
Install-Module -Name Az -Repository PSGallery -Force

更新 Az PowerShell 模块

python 复制代码
Update-Module -Name Az -Force

PowerShell 登录到 Azure

登录到中国区Azure

python 复制代码
Connect-AzAccount -EnvironmentName AzureChinaCloud

国际区

python 复制代码
Connect-AzAccount

PowerShell 登录到 Azure后切换订阅

python 复制代码
Set-AzContext -Subscription 订阅名

Azure 中运行 Windows Server 的 VM 的就地升级

前置条件,生成一块OS磁盘

  • 对服务器创建快照,看公共IP地址是否为静态,不是的话与客户沟通变更为静态公共IP,否则可能会导致更新后公共IP发生变化,如没有公共IP则忽略
  • 已本机管理员权限打开power shell 登录Azure后 执行命令,更新资源组名称 地域后 复制粘贴执行即可
  • 目的是在Azure上生成一块系统镜像磁盘
python 复制代码
Connect-AzAccount -EnvironmentName AzureChinaCloud
python 复制代码
#
# Customer specific parameters


# Resource group of the source VM
$resourceGroup = "资源组名称"

# Location of the source VM
$location = "ChinaNorth2"

# Zone of the source VM, if any
$zone = "" 

# Disk name for the that will be created
$diskName = "WindowsServer2016UpgradeDisk"

# Target version for the upgrade - must be either server2022Upgrade, server2019Upgrade, server2016Upgrade or server2012Upgrade
$sku = "server2016Upgrade"


# Common parameters

$publisher = "MicrosoftWindowsServer"
$offer = "WindowsServerUpgrade"
$managedDiskSKU = "Standard_LRS"

#
# Get the latest version of the special (hidden) VM Image from the Azure Marketplace

$versions = Get-AzVMImage -PublisherName $publisher -Location $location -Offer $offer -Skus $sku | sort-object -Descending {[version] $_.Version	}
$latestString = $versions[0].Version


# Get the special (hidden) VM Image from the Azure Marketplace by version - the image is used to create a disk to upgrade to the new version


$image = Get-AzVMImage -Location $location `
                       -PublisherName $publisher `
                       -Offer $offer `
                       -Skus $sku `
                       -Version $latestString

#
# Create Resource Group if it doesn't exist
#

if (-not (Get-AzResourceGroup -Name $resourceGroup -ErrorAction SilentlyContinue)) {
    New-AzResourceGroup -Name $resourceGroup -Location $location    
}

#
# Create Managed Disk from LUN 0
#

if ($zone){
    $diskConfig = New-AzDiskConfig -SkuName $managedDiskSKU `
                                   -CreateOption FromImage `
                                   -Zone $zone `
                                   -Location $location
} else {
    $diskConfig = New-AzDiskConfig -SkuName $managedDiskSKU `
                                   -CreateOption FromImage `
                                   -Location $location
} 

Set-AzDiskImageReference -Disk $diskConfig -Id $image.Id -Lun 0

New-AzDisk -ResourceGroupName $resourceGroup `
           -DiskName $diskName `
           -Disk $diskConfig

将生成的OS磁盘附件到需升级的服务器

执行就地升级到 Windows Server 2016

  • 远程连接到服务器
  • 确定升级os磁盘的驱动器号
  • 启动 Windows PowerShell
  • 在PowerShell 切换目录到升级os磁盘
python 复制代码
cd  目录名
#例如 cd  D:\BaiduNetdiskDownload\navicat
.\setup.exe /auto upgrade /dynamicupdate disable

大概需要执行4小时左右

  • 通常windows映像的OS磁盘是128G
  • datacenter-core是没有图形化
  • smalldisk指的是OS磁盘使用的是30G

可以在控制台选择"启动诊断"选项以查看日志和屏幕截图。

升级后配置

  • 如果创建了 OS 磁盘和数据磁盘的快照,请将其删除。
  • 删除新建的升级OS磁盘
  • 启用在升级过程开始时可能已禁用的任何防病毒、反间谍软件或防火墙软件
  • 更新漏洞补丁,关闭自动更新

故障恢复

如果就地升级过程未能成功完成,在创建了操作系统磁盘和数据磁盘快照的情况下,可以返回到 VM 的先前版本。

相关推荐
zandy101116 小时前
联想集团:AI创新标杆,定义智能时代企业创新新范式
大数据·人工智能·microsoft·联想
Allen Su17 小时前
【Mac 教程系列第 19 篇】如何将 macOS 中的 Microsoft AutoUpdate 软件从系统中删除
microsoft·macos·autoupdate
江沉晚呤时19 小时前
用 C# 玩转 Scriban:自动生成报告、代码、文本,效率提升 10 倍
数据库·microsoft·c#·.net
熊文豪1 天前
从零到一的AI产品演进:用Claude Code与蓝耘MaaS打造多模型聚合聊天工具全纪实
人工智能·microsoft·蓝耘
装杯让你飞起来啊2 天前
第 4 周 Unit 2:Jetpack Compose 状态、按钮、计数器与小费计算器
windows·microsoft·kotlin·安卓
生信之灵2 天前
追踪17只果蝇、7只线虫、10只小鼠,全程无需人工标注:这个无监督跟踪器如何颠覆动物行为研究?
人工智能·深度学习·神经网络·microsoft·交互
雪度娃娃2 天前
创建型设计模式——建造者模式
c++·microsoft·设计模式·建造者模式
IT技术分享社区2 天前
C盘飙红、开机一分钟?用这个工具一键清理,电脑速度快得像新买的
windows·microsoft·微软·电脑软件
装杯让你飞起来啊2 天前
第 2 周 Day 5-6:综合小游戏 —— 学生成绩管理系统
windows·microsoft·kotlin