• Azure自动化实例: 复制blog用于备份


    在Azure 自动化:使用PowerShell Credential连接到Azure, 之后, 我在项目中遇到了实现blog备份的任务, 现将其作为一个实例写下来:

    1. 首先,创建自动化帐户, 在资产中, 创建以下资产:

    • 创建PowerShell连接Credential

    变量名:PSCredential , 设置为您的自动化账户邮箱和密码。

    • 创建脚本中要使用的字符串变量:脚本中调用的变量包括:订阅名称(SubscriptionName)、存储帐户(StorageAccountName)、容器名称(ContainerName)、源blog名(BlogName)。

    2. 在Runbook中,导入自动化脚本:

    workflow CopyBlog
    {
    #sign in
    #Add-AzureAccount
    $Credential = Get-AutomationPSCredential -Name "PSCredential"
    $SubscriptionName = Get-AutomationVariable -Name "SubscriptionName"
    $storN = Get-AutomationVariable -Name "StorageAccountName"
    $containerN = Get-AutomationVariable -Name "ContainerName"
    $srcname= Get-AutomationVariable -Name "BlogName"
    #connect to Azure using PowerShell Credential
    Add-AzureAccount -Credential $Credential
    
    #Select the Azure subscription to use in this workflow
    Select-AzureSubscription -SubscriptionName $SubscriptionName
    
    Set-AzureSubscription -SubscriptionName $SubscriptionName -CurrentStorageAccountName $storN
    
    # copy from srcblog to trgblog
    
    $thedatetime=get-date -Format 'yyyyMMddhhmmss'
    $trgname="{0}.vhd" -f $thedatetime
    Write-Verbose $trgname
    Start-AzureStorageBlobCopy -SrcBlob $srcname -SrcContainer $containerN -DestContainer $containerN -DestBlob $trgname 
    }


    发布runbook并设置自动运行规则:

    每15天备份一次。

    步骤:

    1. 在选项卡中,单击Schedule
    2. 单击LINK TO A NEW SCHEDULE。
    3. 在Add Schedule,  Configure Schedule中, 选择DAILY。
    4. 在RECUR EVERY中,输入15。
    5. 单击完成
  • 相关阅读:
    Matlab画图-非常具体,非常全面
    PostgreSQL代码分析,查询优化部分,pull_ands()和pull_ors()
    Windows内核
    [WebGL入门]十,矩阵计算和外部库
    HOG特征-理解篇
    hdu 5035 概率论
    Hibernate对象持久化框架
    Thinkpad X200 屏幕备案
    64地点 Windows 8/7 根据系统 32地点PLSQL 耦合 64 地点 Oracle 11g
    阐述php(四) 流量控制
  • 原文地址:https://www.cnblogs.com/qixue/p/4500389.html
Copyright © 2020-2023  润新知