2013-07-26 53 views
2

我已經成功地在Azure中創建一個虛擬機,並使用了以下導出其設置,然後刪除VM和服務:(400)錯誤的請求時使用新AzureVM命令行

export-azurevm -servicename "testautomation" -name "testautomation" -path "C:\azurestates\testautomation.xml"

remove-azurevm -servicename "testautomation" -name "testautomation"

然而,當我嘗試重新創建VM,我得到如下:

PS C:> import-azurevm -path "C:\azurestates\testautomation.xml" | new-azurevm -servicename 'testautomation' -location "east us"

new-azurevm : The remote server returned an unexpected response: (400) Bad Request. At line:1 char:60 + import-azurevm -path "C:\azurestates\testautomation.xml" | new-azurevm -servicen ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureVM], ProtocolException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand

這好像應該是很簡單的,我不太清楚,我要去哪裏錯了。在使用New-AzureVMConfig時,谷歌搜索這個錯誤指出了我的一些變化,但我不確定如何繼續,因爲我沒有使用它。任何援助將不勝感激。

回答

2

問題出在我的Set-AzureSubscription commandlet。我在該命令中大寫了存儲帳戶,最終導致了我在這裏遇到的問題。我花了一段時間來追蹤它,因爲我沒有想過要仔細檢查這個命令,因爲我通過PowerShell執行的所有其他操作都在工作。非常感謝您的幫助和代碼,以查明內部異常(這是解決問題的關鍵)!

4

你可以得到什麼地方出了錯通過在內部異常考慮看看更多的細節:

PS C:\> $sr = new-object System.IO.StreamReader($Error[0].Exception.InnerException.Response.GetResponseStream()) 
PS C:\> $txt = $sr.ReadToEnd() 
PS C:\> $txt 
PS C:\> $sr.Close() 

第三個命令應打印出什麼是錯的新AzureVM通話更詳細的錯誤信息。

+0

我將不得不把它放在我的後袋以備將來排除故障。謝謝!因此顯示的錯誤是這樣的: 'code'BadRequest na 我不是有效的存儲帳戶名稱。存儲帳戶名稱的長度必須介於3到24個字符之間,並且只能使用數字和小寫字母 。 'code' –

+0

我很迷惑,爲什麼我得到這個錯誤。我正在使用Set-AzureSubscription和Select-AzureSubscription,並且可以成功將VHD上傳到Azure。更多的幫助,可以嗎? –

+0

我要創建一個新的問題來解決這個特定的錯誤。非常感謝代碼,使其易讀! –