[英]Deploy Azure Cloud Service using Azure Automation Powershell DSC
[英]Using Azure Automation to create a cloud service instance using Powershell
我正在嘗試編寫一個腳本,該腳本可以在Azure上自動化以創建雲服務的新實例。 我在使New-AzureDeployment cmdlet正常工作時遇到麻煩。
CSPKG和CSCFG文件都以相同的存儲帳戶存儲在Azure上,但存儲在不同的容器中。 它們是使用CloudBerry上傳的。
param(
[parameter(Mandatory=$False)]
[string] $StorageAccount = 'storageaccount',
[parameter(Mandatory=$False)]
[string] $ServiceName = 'cloudservicesdev',
[parameter(Mandatory=$False)]
[string] $Slot = 'Production',
[parameter(Mandatory=$False)]
[string] $Label = 'BASE'
)
Write-Output "Start of workflow"
$cert = Get-AutomationCertificate -Name 'Credential'
$subID = 'subId'
Set-AzureSubscription -SubscriptionName "SubName" -CurrentStorageAccountName $StorageAccount -Certificate $cert -SubscriptionId $subID
Select-AzureSubscription "SubName"
$package = (Get-AzureStorageBlob -blob "package.cspkg" -Container "package").ICloudBlob.uri.AbsoluteUri
$config = (Get-AzureStorageBlob -blob "Config - Dev.cscfg" -Container "config").ICloudBlob.uri.AbsoluteUri
New-AzureDeployment -ServiceName "$ServiceName" -Slot "$Slot" -Package "$package" -Configuration "$config" -Label "$Label"
我收到以下錯誤
2014-12-08 05:57:57 PM, Error: New-AzureDeployment : The given path's format is not supported.
At Create_New_Cloud_Service_Instance:40 char:40
+
+ CategoryInfo : NotSpecified: (:) [New-AzureDeployment], NotSupportedException
+ FullyQualifiedErrorId :
System.NotSupportedException,Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.NewAzureDeploymentCommand
我已經檢查了$ package和$ config變量,它們都指向了我期望的文件位置( https://storageaccount.blob.core.windows.net/package/package.cspkg和https:// storageaccount .blob.core.windows.net / config / Config%20-%20Dev.cscfg )。 它們與我導航到“存儲”中其容器下的文件時看到的URL匹配。
這看起來類似於我所看到的示例。 我做錯了什么?
這是我根據喬下面的答案使用的新代碼
我還使用了此示例腳本https://gallery.technet.microsoft.com/scriptcenter/Continuous-Deployment-of-A-eeebf3a6來幫助使用Azure自動化沙箱
param(
[parameter(Mandatory=$False)]
[string] $StorageAccount = 'storageaccount',
[parameter(Mandatory=$False)]
[string] $ServiceName = 'cloudservicesdev',
[parameter(Mandatory=$False)]
[string] $Slot = 'Production',
[parameter(Mandatory=$False)]
[string] $Label = 'BASE'
)
Write-Output "Start of workflow"
$cert = Get-AutomationCertificate -Name 'Credential'
$subID = 'subId'
Set-AzureSubscription -SubscriptionName "SubName" -CurrentStorageAccountName $StorageAccount -Certificate $cert -SubscriptionId $subID
Select-AzureSubscription "SubName"
$package = (Get-AzureStorageBlob -blob "package.cspkg" -Container "package").ICloudBlob.uri.AbsoluteUri
$TempFileLocation = "C:\temp\Config - Dev.cscfg"
$config = (Get-AzureStorageBlobContent -blob "Config - Dev.cscfg" -Container "config" -Destination $TempFileLocation -Force)
New-AzureDeployment -ServiceName "$ServiceName" -Slot "$Slot" -Package "$package" -Configuration $TempFileLocation -Label "$Label"
在執行操作時,應將New-AzureDeployment的-Package參數傳遞給存儲URI,但是-Configuration參數需要一個本地文件。 有關更多詳細信息,請參見http://msdn.microsoft.com/zh-cn/library/azure/dn495143.aspx 。
因此,您需要在運行手冊中,將$ config URI處的文件下載到Azure自動化沙箱,然后將該文件的本地路徑傳遞給New-AzureDeployment。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.