azure - Azure ARM:使用访问密钥从存储帐户创建 Linux VM
问题描述
是否可以使用 ARM 模板在 Azure 中创建虚拟机(Ubuntu Linux),我将在其中将 .vhd 文件存储在存储帐户中,并且在单独的 Azure 资源组(客户端)中部署时,将使用 access 访问存储帐户部署 VM 的密钥。
我使用以下命令将 VHD 复制到我的 RG 中的存储帐户。
az storage blob copy start --destination-blob $destinationVHDFileName
--destination-container $storageContainerName --account-name $storageAccountName
--account-key $storageAccountKey --source-uri $sas
解决方案
如果要使用自己的 vhd 文件创建 Vm,可以使用 VHD 文件创建 Azure 托管映像,然后使用该映像创建 VM。有关更多详细信息,请参阅此处和此处
例如
- 创建 Azure 托管映像
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"images_testimage_name": {
"defaultValue": "testimage1",
"type": "String"
},
"blobUri": {
"defaultValue": "<your vhd file url>",
"type": "String"
},
"location": {
"defaultValue": "",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Compute/images",
"apiVersion": "2019-07-01",
"name": "[parameters('images_testimage_name')]",
"location": "[parameters('location')]",
"properties": {
"storageProfile": {
"osDisk": {
"osType": "Linux",
"osState": "Generalized",
"diskSizeGB": 30,
"blobUri": "[parameters('blobUri')]",
"caching": "ReadWrite",
"storageAccountType": "Premium_LRS"
},
"dataDisks": [],
"zoneResilient": true
},
"hyperVGeneration": "V1"
}
}
]
}
- 创建虚拟机
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {},
"resources": [
... other resource
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"location": "[parameters('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "Premium_LRS"
}
},
"imageReference": {
"id": "<the resource id of the image you create in step1>"
}
},
... other configurations
}
}
]
}
推荐阅读
- excel - Excel VBA - 创建记录表
- c++ - 仅当它不是别名时,如何编写 std::chrono::high_resolution 时钟类模板专业化
- php - 需要模态在另一个项目文件夹 Bootsrap 4 中不起作用
- google-analytics - GTM 仅在调试模式下触发我的标签。在实时模式下,它仅适用于 Chrome
- java - Spring boot 2 使用 AWS API Gateway 激活 spring 配置文件
- android - Android 上的 Web 推送通知
- swiftui - 从 datepicker 获取和设置日期,但仍然获得旧的默认值
- reactjs - 命令 C 不会阻止本地服务器在 VS 代码上运行
- c# - 如何在 Syncfusion Blazor 中以全宽和自动高度显示整个世界地图?
- text2vec - text2vec 包中的 glove_event$fit_transform 错误