我想每天为我的天蓝色服务器创建一个备份...
为此,我正在使用此链接:
https://gallery.technet.microsoft.com/scriptcenter/Back-up-an-Azure-VM-using-9545f0a1#content
http://blogs.technet.com/b/cbernier/archive/2014/04/08/microsoft-azure-automation.aspx
我创建了一个自动化“knsazureautomation”,其中我手动创建了 1 个运行手册“knsremotepscommand”,并导入了两个文件:
- Connect-Azure:/scriptcenter/Connect-to-an-Azure-f27a81bb - 下载此脚本
- Connect-AzureVM:/scriptcenter/Connect-to-an-Azure-85f0782c - 下载此脚本
和 knsremotepscommand 的工作流程(>作者>草稿)
workflow knsremotepscommand
{
Param
(
[parameter(Mandatory=$true)]
[String]
$AzureSubscriptionName,
[parameter(Mandatory=$true)]
[PSCredential]
$AzureOrgIdCredential,
[parameter(Mandatory=$true)]
[String]
$ServiceName,
[parameter(Mandatory=$true)]
[String]
$VMName,
[parameter(Mandatory=$true)]
[String]
$VMCredentialName,
[parameter(Mandatory=$true)]
[String]
$PSCommand
)
# Get credentials to Azure VM
$Credential = Get-AutomationPSCredential -Name $VMCredentialName
if ($Credential -eq $null)
{
throw "Could not retrieve '$VMCredentialName' credential asset. Check that you created this asset in the Automation service."
}
# Set up Azure connection by calling the Connect-Azure runbook. You should call this runbook after
# every CheckPoint-WorkFlow to ensure that the management certificate is available if this runbook
# gets interrupted and starts from the last checkpoint
$Uri = Connect-AzureVM -AzureSubscriptionName $AzureSubscriptionName -AzureOrgIdCredential $AzureOrgIdCredential -ServiceName $ServiceName -VMName $VMName
# Run a command on the Azure VM
$PSCommandResult = InlineScript {
Invoke-command -ConnectionUri $Using:Uri -credential $Using:Credential -ScriptBlock {
Invoke-Expression $Args[0]
} -Args $Using:PSCommand
}
$PSCommandResult
}
和创建的资产是
创建自动化:
Account Name: KNSAzureAutomation Region:EAST US 2
评估:
添加连接
Configure connection CONNECTION TYPE:azure NAME: KNSAzureConnection AUTOMATIONCERTIFICATENAME:KNSAzureCertificationName SUBSCRIPTIONID: (my azure subscrption id is given)
添加凭据
CREDENTIAL TYPE:WindowsPowerShell Credential NAME:KNSAzureCredential
添加时间表
Configure Schedule NAME:KnsAzureBackup1 DESCRIPTION: first backuschedule everaday at 12.45 SELECTED RUNBOOK KNSremotePScommand AZUREORGIDCREDENTIAL:vnalluri2006@hotmail.com AZURESUBSCRIPTIONNAME:BizSpark PSCOMMAND:ipconfig/all SERVICENAME:KNSWin VMCREDENTIALNAME:KNSAzureCredential(Asset Credential name) VMNAME:knsazurewin1
我收到此错误:
找不到帐户“3c2455db-035a-477c-b20c-51fd74a586fa”的名称为“vnalluri2006@hotmail.com”的凭据。
如果我更改凭据
AZUREORGIDCREDENTIAL:vnalluri2006@hotmail.com
至
AZUREORGIDCREDENTIAL:KNSAzureCredential
我收到此错误:
4/22/2015 4:53:11 PM, Error: Add-AzureAccount : -Credential parameter can only be used with Organization ID credentials. For more information,
please refer to for more information about the difference
between an organizational account and a Microsoft account.
At Connect-AzureVM:24 char:24
+
+ CategoryInfo : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
4/22/2015 4:53:12 PM, Error: Select-AzureSubscription : The subscription name BizSpark doesn't exist.
Parameter name: name
At Connect-AzureVM:27 char:27
+
+ CategoryInfo : CloseError: (:) [Select-AzureSubscription], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SelectAzureSubscriptionCommand
4/22/2015 4:53:17 PM, Error: Get-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to
set the default subscription.
At Connect-AzureVM:29 char:29
+
+ CategoryInfo : CloseError: (:) [Get-AzureVM], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
4/22/2015 4:53:17 PM, Error: Get-AzureCertificate : Cannot validate argument on parameter 'Thumbprint'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At Connect-AzureVM:29 char:29
+
+ CategoryInfo : InvalidData: (:) [Get-AzureCertificate], ParameterBindingValidationException
+ FullyQualifiedErrorId :
ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.ServiceManagement.Certificates.GetAzureCertificate
4/22/2015 4:53:17 PM, Error: Get-AzureWinRMUri : No default subscription has been designated. Use Select-AzureSubscription -Default
<subscriptionName> to set the default subscription.
At Connect-AzureVM:29 char:29
+
+ CategoryInfo : CloseError: (:) [Get-AzureWinRMUri], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureWinRMUri
4/22/2015 4:53:17 PM, Error: Invoke-Command : Cannot validate argument on parameter 'ConnectionUri'. The argument is null, empty, or an element of
the argument collection contains a null value. Supply a collection that does not contain any null values and then try
the command again.
At knsremotepscommand:92 char:92
+
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand