用于创建OSDisk和DataDisk快照的Powershell命令

问题描述 投票:0回答:1

我正在编写powershell脚本来捕获Azure VM的操作系统磁盘快照但是在配置快照时我收到了一些错误。我使用下面的命令来创建快照。我正在使用托管磁盘。

New-AzSnapshotConfig -OsType Linux -CreateOption copy -SourceUri Microsoft.Azure.Management.Compute.Models.OSDisk -DiskSizeGB 40 -Location 'East US'

不知道该怎么做。如果有人能帮助我解决这个问题。

OUTPUT

WARNING: Breaking changes in the cmdlet 'New-AzSnapshotConfig' :
WARNING:  - "The output type 'Microsoft.Azure.Commands.Compute.Automation.Models.PSSnapshot' is changing"
 - The following properties in the output type are being deprecated :
 'EncryptionSettings'
- The following properties are being added to the output type :
 'EncryptionSettingsCollection' 'HyperVGeneration'


WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in 
Azure PowerShell.


ResourceGroupName            : 
ManagedBy                    : 
Sku                          : 
TimeCreated                  : 
OsType                       : Linux
HyperVGeneration             : 
CreationData                 : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB                   : 40
EncryptionSettingsCollection : 
ProvisioningState            : 
Id                           : 
Name                         : 
Type                         : 
Location                     : East US
Tags                         : 
EncryptionSettings           : 

Thanks
Rohit
powershell snapshot
1个回答
0
投票

您是否转到警告说明中提供的链接?它says very clearly

我如何摆脱警告?

要禁止显示这些警告消息,请将环境变量“SuppressAzurePowerShellBreakingChangeWarnings”设置为“true”。

Set-Item Env:\ SuppressAzurePowerShellBreakingChangeWarnings“true”

错误消息试图告诉您,您在提供的输出中看到的属性EncryptionSettings将很快从某种类型的单个属性更改为您必须迭代以查找所有设置的集合属性。他们试图告诉您,如果您将New-AzSnapshotConfig的输出捕获到变量然后调用$variable.EncryptionSettings,您的代码现在可以正常工作,但在下一个重大更改版本中,该调用将停止工作。最有可能的是,由于该属性将不再存在,该调用的结果将只是一个$NULL

所以请自行承担压制此警告的风险,因为Microsoft正在尝试为您提供服务,并告诉您如果您不对此进行操作,您的代码可能会中断。但如果您确定自己从未引用过财产,那么您无需担心。

© www.soinside.com 2019 - 2024. All rights reserved.