代码之家  ›  专栏  ›  技术社区  ›  Luis Valencia

其中Azure快照与此脚本一起存储

  •  0
  • Luis Valencia  · 技术社区  · 6 年前

    我找到了这个博客帖子

    https://www.techmanyu.com/automate-disk-snapshots-azure/

    作者展示了这个脚本。

    $clientID = "<client id>"
    $key = "<client secret>"
    $SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientID, $SecurePassword
    Add-AzureRmAccount -Credential $cred -Tenant "<Tenant ID>" -ServicePrincipal;
    $disks=Get-AzureRmDisk | Select Name,Tags,Id,Location,ResourceGroupName ; 
    foreach($disk in $disks) { foreach($tag in $disk.Tags) { if($tag.Snapshot -eq 'True') {$snapshotconfig = New-AzureRmSnapshotConfig -SourceUri $disk.Id -CreateOption Copy -Location $disk.Location -AccountType PremiumLRS;$SnapshotName=$disk.Name+(Get-Date -Format "yyyy-MM-dd");New-AzureRmSnapshot -Snapshot $snapshotconfig -SnapshotName $SnapshotName -ResourceGroupName $disk.ResourceGroupName }}}
    

    为了理解脚本,我提出了一个问题,快照存储在哪里?在与虚拟机磁盘相同的管理磁盘中?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Joy Wang    6 年前

    在执行脚本之后,它将创建快照,您可以在门户中检查它们,它们的资源类型为 Microsoft.Compute/snapshots . 基本上,它们应该存储在blob存储中。导航到门户中的快照->导出,然后您会发现它生成快照的SAS令牌,如 https://md-nxxxqz.blob.core.windows.net/wxxxxxx0m/abcd?sv=2017-04-17&sr=b&si=31b3d91b-51be-4c1c-930e-996f382b8ad9&sig=xxxxxx . 这个 md-nxxxqz 是存储快照的存储帐户,由Azure管理。

    推荐文章