簡體   English   中英

使用Python在Azure中從磁盤創建Linux虛擬機

[英]Creating a linux virtual machine from disk in azure using python

我想使用python從azure中的磁盤上創建Linux虛擬機。 我找到了一些建議使用VHD某些操作的鏈接,但並未明確說明如何執行此操作。 任何人都可以使用python解釋答案(不在CLIpowershellJSON )。

我已參考此文檔

VM_PARAMETERS = {

            'location': LOCATION,
            'os_profile': {
                'computer_name': VM_NAME,
                'admin_username': USERNAME,
                'admin_password': PASSWORD
            },
            'hardware_profile': {
                'vm_size': 'Basic_A0'
            },
            'storage_profile': {
                'image_reference': {
                    'publisher': 'Canonical',
                    'offer': 'UbuntuServer',
                    'sku': '16.04.0-LTS',
                    'version': 'latest'
                },
            },
            'network_profile': {
                'network_interfaces': [{
                    'id': nic_id,
                }]
            },

}

compute_client.virtual_machines.create_or_update(GROUP_NAME, VM_NAME, VM_PARAMETERS)

請幫我解決一下這個。

你特別問...

任何人都可以使用python解釋答案(不在CLI或powershell或JSON上)

但是,您是在PowerShell問答論壇中提問。

那您不應該在python論壇上問這個問題嗎? https://stackoverflow.com/questions/tagged/python

話雖如此。 VHD是虛擬硬盤。 您必須首先安裝一個虛擬機才能連接到虛擬機,以啟動虛擬機。

如何使用Azurerm Python庫創建Azure VM

至少有兩種方法可以使用Python使用Azure基礎結構。 您可以使用支持所有Azure功能的官方適用於Python的Azure SDK,或使用非官方的Azureure REST包裝器庫,並支持一部分Azure REST API。

https://msftstack.wordpress.com/2016/08/05/how-to-create-an-azure-vm-with-the-azurerm-python-library

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM