Azure REST API不会返回虚拟机

时间:2017-11-16 14:31:37

标签: rest azure encryption azure-virtual-machine

我的Azure帐户中有一个16.04-LTS Ubuntu虚拟机,我正在尝试Azure Disk Encryption使用this azure cli sample script这个虚拟机。在运行加密脚本时,azure门户显示其操作系统磁盘已加密。加密标题下有Enabledenter image description here

但是,用于获取有关虚拟机的信息的Azure REST API(api link)不会返回encryptionSettings下的properties.storageProfile.osDisk。我为api-version Model View以及Model View and Instance View尝试了2017-03-302017-12-01。以下是API的部分响应:

{
    "name": "ubuntu",
    "properties": {
        "osProfile": {},
        "networkProfile": {},
        "storageProfile": {
            "imageReference": {
                "sku": "16.04-LTS",
                "publisher": "Canonical",
                "version": "latest",
                "offer": "UbuntuServer"
            },
            "osDisk": {
                "name": "ubuntu-OsDisk",
                "diskSizeGB": 30,
                "managedDisk": {
                    "storageAccountType": "Premium_LRS",
                    "id": "..."
                },
                "caching": "ReadWrite",
                "createOption": "FromImage",
                "osType": "Linux"
            },
            "dataDisks": []
        },
        "diagnosticsProfile": {},
        "vmId": "",
        "hardwareProfile": {
            "vmSize": "Standard_B1s"
        },
        "provisioningState": "Succeeded"
    },
    "location": "eastus",
    "type": "Microsoft.Compute/virtualMachines",
    "id": ""
}

但是对于我的其他加密的Windows虚拟机,我得到了encryptionSettings中包含properties.storageProfile.osDisk的正确回复:

{
    "name": "win1",
    "properties": {
        "osProfile": {},
        "networkProfile": {},
        "storageProfile": {
            "imageReference": {
                "sku": "2016-Datacenter-smalldisk",
                "publisher": "MicrosoftWindowsServer",
                "version": "latest",
                "offer": "WindowsServer"
            },
            "osDisk": {
                "name": "win1_OsDisk_1",
                "diskSizeGB": 31,
                "managedDisk": {
                    "storageAccountType": "Premium_LRS",
                    "id": "..."
                },
                "encryptionSettings": {
                    "diskEncryptionKey": {
                        "secretUrl": "...",
                        "sourceVault": {
                            "id": "..."
                        }
                    },
                    "keyEncryptionKey": {
                        "keyUrl": "...",
                        "sourceVault": {
                            "id": "..."
                        }
                    },
                    "enabled": true
                },
                "caching": "ReadWrite",
                "createOption": "FromImage",
                "osType": "Windows"
            },
            "dataDisks": []
        },
        "diagnosticsProfile": {},
        "vmId": "...",
        "hardwareProfile": {
            "vmSize": "Standard_B1s"
        },
        "provisioningState": "Succeeded"
    },
    "location": "eastus",
    "type": "Microsoft.Compute/virtualMachines",
    "id": "..."
}

为什么虚拟机Get API没有为某些VM返回encryptionSettings?任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

我使用以下命令创建VM。

az vm create \
    --resource-group shuivm \
    --name shuivm \
    --image Canonical:UbuntuServer:16.04-LTS:latest \
    --admin-username azureuser \
    --generate-ssh-keys

当我使用以下API时,我可以进行加密设置。

https://management.azure.com/subscriptions/**********/resourceGroups/shuivm/providers/Microsoft.Compute/virtualMachines/shuivm?api-version=2017-03-30"

enter image description here

注意:当OS加密成功时,我可以使用API​​来获取加密设置。

答案 1 :(得分:0)

这是因为Azure VM有两种类型的静态磁盘加密,并且它们未在Azure Management API的同一部分中报告:

  • 服务器端加密:获取虚拟机详细信息后,您可以在VM / compute API的encryptionSettings部分中看到。它将显示您是使用客户管理密钥还是平台管理密钥
  • ADE :Azure磁盘加密实际上是VM扩展,因此您可以在VM Extension API中找到它。

请参阅:https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineextensions/list