我有應用程序與存儲帳戶和磁盤部署虛擬機,我想將其轉換爲使用託管磁盤 - 因爲這是Azure存儲的未來。我期待的REST API - 和我丟失了兩兩件事:1。 如何創建現有管理磁盤快照的形式,有創建快照的API,但它是空的或舊的非託管 2.我可以選擇創建磁盤的LUN?天青 - 管理的磁盤,如何創建快照
0
A
回答
2
- 如何創建現有管理磁盤快照的形式,有創建快照的API,但它是空的或舊的非託管
根據您的描述中,我創建了一個測試演示來創建現有託管磁盤(操作系統磁盤)的快照,它運行良好。 我創建一個Windows VM並使用託管磁盤作爲操作系統磁盤,然後創建另一個託管磁盤並將其添加到虛擬機。
結果如下圖所示: 如果要創建現有管理磁盤(它的數據)的快照,我建議你可以發送請求到以下網址。
Url: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{snapshotName}?api-version={api-version}
Method: PUT
Parameter:
subscriptionId The identifier of your subscription where the snapshot is being created.
resourceGroup The name of the resource group that will contain the snapshot.
snapshotName The name of the snapshot that is being created. The name can’t be changed after the snapshot is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
api-version The version of the API to use. The current version is 2016-04-30-preview.
Request content:
{
"properties": {
"creationData": {
"createOption": "Copy",
"sourceUri": "/subscriptions/{subscriptionId}/resourceGroups/{YourResourceGroup}/providers/Microsoft.Compute/disks/{YourManagedDiskName}"
}
},
"location": "eastasia"
}
更多細節,你可以參考遵循C#代碼:
json.txt:
{
"properties": {
"creationData": {
"createOption": "Copy",
"sourceUri": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/BrandoSecondTest/providers/Microsoft.Compute/disks/BrandoTestVM"
}
},
"location": "eastasia"
}
代碼:
static void Main(string[] args)
{
string body = File.ReadAllText(@"D:\json.txt");
// Display the file contents to the console. Variable text is a string.
string tenantId = "xxxxxxxxxxxxxxxxxxxxxxxx";
string clientId = "xxxxxxxxxxxxxxxxxxxxxxxx";
string clientSecret = "xxxxxxxxxxxxxxxxxxxx";
string authContextURL = "https://login.windows.net/" + tenantId;
var authenticationContext = new AuthenticationContext(authContextURL);
var credential = new ClientCredential(clientId, clientSecret);
var result = authenticationContext.AcquireTokenAsync(resource: "https://management.azure.com/", clientCredential: credential).Result;
if (result == null)
{
throw new InvalidOperationException("Failed to obtain the JWT token");
}
string token = result.AccessToken;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://management.azure.com/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxxxx/providers/Microsoft.Compute/snapshots/BrandoTestVM_snapshot2?api-version=2016-04-30-preview");
request.Method = "PUT";
request.Headers["Authorization"] = "Bearer " + token;
request.ContentType = "application/json";
try
{
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(body);
streamWriter.Flush();
streamWriter.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
//Get the response
var httpResponse = (HttpWebResponse)request.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
Console.WriteLine(streamReader.ReadToEnd());
}
Console.ReadLine();
}
- 可以我選擇在其上創建該磁盤綸?
你的意思是你想用azuredeploy選擇磁盤的LUN?
如果這是你的意見,我建議你可以參考遵循JSON的例子來了解如何建立虛擬機的部署內容,並選擇它的LUN。
更多細節,你可以參考下面deploymentTemplate JSON(晴):
"diskArray": [
{
"name": "datadisk1",
"lun": 0,
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk1.vhd')]"
},
"createOption": "Empty",
"caching": "[variables('diskCaching')]",
"diskSizeGB": "[variables('sizeOfDataDisksInGB')]"
},
]
更多細節,你可以參考以下網站: 201-vm-dynamic-data-disks-selection/azuredeploy.json
相關問題
- 1. 如何爲天青虛擬機創建數據磁盤?
- 2. 還原管理OS磁盤快照到現有VM
- 3. 天青創建
- 4. 谷歌計算引擎磁盤快照卡在創建
- 5. Azure的磁盤管理
- 6. 我的虛擬機上添加磁盤天青
- 7. 如何創建磁盤的映像?
- 8. 爲Google部署管理器創建空磁盤
- 9. cassandra的物理磁盤空間管理
- 10. 如何從快照創建天藍色的圖像?
- 11. 天青asm重新分配vhd租賃到磁盤後中斷
- 12. 如何使用VHD-UTIL管理快照
- 13. 正在尋找快照Maven倉庫清理腳本(UNIX)構建(磁盤空間)
- 14. 如何創建可啓動磁盤
- 15. 如何使用Node.js創建RAM磁盤?
- 16. 如何從MemoryStream創建磁盤(VB.net)
- 17. 谷歌計算引擎:磁盤快照和磁盤映像有什麼區別?
- 18. urllib.urlretrieve在磁盤上創建
- 19. 如何將蔚藍色磁盤還原到其以前的快照?
- 20. 創建新磁盤時gcloud中的磁盤類型混淆
- 21. 託管磁盤和非託管磁盤之間的區別
- 22. 天青如何處理DeviceClient.CompleteAsync(消息)
- 23. 增加了天青集裝箱服務
- 24. 如何在Nest中創建快照?
- 25. RDS快照管理的AWS/IAM策略?
- 26. 在巴西創建天青虛擬機
- 27. 天青 - 編程創建存儲帳戶
- 28. 天青 - 無法創建SQL數據庫
- 29. 上傳BLOB天青 - 創建認證頭
- 30. 天青 - 創建SSL公鑰編程