|
| 1 | +--- |
| 2 | +title: Issues using VM extensions in Python 3-enabled Linux Azure Virtual Machines systems |
| 3 | +description: Learn about using VM extensions in Python 3-enabled Linux systems |
| 4 | +services: virtual-machines-windows |
| 5 | +documentationcenter: '' |
| 6 | +author: v-miegge |
| 7 | +ms.author: jparrel |
| 8 | +manager: dcscontentpm |
| 9 | +editor: '' |
| 10 | +tags: top-support-issue,azure-resource-manager |
| 11 | + |
| 12 | +ms.service: virtual-machines-windows |
| 13 | +ms.topic: article |
| 14 | +ms.tgt_pltfrm: vm-windows |
| 15 | +ms.workload: infrastructure-services |
| 16 | +ms.date: 04/22/2020 |
| 17 | +ms.assetid: 3cd520fd-eaf7-4ef9-b4d3-4827057e5028 |
| 18 | +--- |
| 19 | + |
| 20 | +# Issues using VM extensions in Python 3-enabled Linux Azure Virtual Machines systems |
| 21 | + |
| 22 | +> [!NOTE] |
| 23 | +> Microsoft encourages users to adopt **Python 3.x** in their systems unless your workload requires **Python 2.x** support. Examples of this requirement might include legacy administration scripts, or extensions such as **Azure Disk Encryption** and **Azure Monitor**. |
| 24 | +> |
| 25 | +> Before installing **Python 2.x** in production, consider the question of long-term support of Python 2.x, particularly their ability to receive security updates. As products, including some of the extension mentioned, update with **Python 3.8** support, you should discontinue use of Python 2.x. |
| 26 | +
|
| 27 | +Some Linux distributions have transitioned to Python 3.8 and removed the legacy `/usr/bin/python` entrypoint for Python altogether. This transition impacts the out-of-the-box, automated deployment of certain virtual machine (VM) extensions with the following conditions: |
| 28 | + |
| 29 | +- Extensions that are still transitioning to Python 3.x support |
| 30 | +- Extensions that use the legacy `/usr/bin/python` entrypoint |
| 31 | + |
| 32 | +Linux distribution users who have transitioned to **Python 3.x** must ensure the legacy `/usr/bin/python` entrypoint exists before attempting to deploy those extensions to their VMs. Otherwise, the extension deployment might fail. |
| 33 | + |
| 34 | +- Endorsed Linux distributions that are affected include **Ubuntu Server 20.04 LTS** and **Ubuntu Pro 20.04 LTS**. |
| 35 | + |
| 36 | +- Affected VM Extensions include **Azure Disk Encryption**, **Log Analytics**, **VM Access** (used for Password Reset), and **Guest Diagnostics** (used for additional performance counters). |
| 37 | + |
| 38 | +In-place upgrades, such as upgrading from **Ubuntu 18.04 LTS** to **Ubuntu 20.04 LTS**, should retain the `/usr/bin/python` symlink, and remain unaffected. |
| 39 | + |
| 40 | +## Resolution |
| 41 | + |
| 42 | +Consider the following general recommendations before deploying extensions in the known-affected scenarios described previously in the Summary: |
| 43 | + |
| 44 | +1. Before deploying the extension, reinstate the `/usr/bin/python` symlink by using the Linux distribution vendor-provided method. |
| 45 | + |
| 46 | + - For example, for **Python 2.7**, use: `sudo apt update && sudo apt install python-is-python2` |
| 47 | + |
| 48 | +2. If you’ve already deployed an instance that exhibits this problem, use the **Run command** functionality in the **VM blade** to run the commands mentioned above. The Run command extension itself is not affected by the transition to Python 3.8. |
| 49 | + |
| 50 | +3. If you are deploying a new instance, and need to set an extension at provisioning time, use **cloud-init** user data to install the packages mentioned above. |
| 51 | + |
| 52 | + For example, for Python 2.7: |
| 53 | + |
| 54 | + ``` |
| 55 | + # create cloud-init config |
| 56 | + cat > cloudinitConfig.json <<EOF |
| 57 | + #cloud-config |
| 58 | + package_update: true |
| 59 | + |
| 60 | + runcmd: |
| 61 | + - sudo apt update |
| 62 | + - sudo apt install python-is-python2 |
| 63 | + EOF |
| 64 | + |
| 65 | + # create VM |
| 66 | + az vm create \ |
| 67 | + --resource-group <resourceGroupName> \ |
| 68 | + --name <vmName> \ |
| 69 | + --image <Ubuntu 20.04 Image URN> \ |
| 70 | + --admin-username azadmin \ |
| 71 | + --ssh-key-value "<sshPubKey>" \ |
| 72 | + --custom-data ./cloudinitConfig.json |
| 73 | + ``` |
| 74 | + |
| 75 | +4. If your organization’s policy administrators determine that extensions shouldn’t be deployed in VMs, you can disable extension support at provisioning time: |
| 76 | + |
| 77 | + - REST API |
| 78 | + |
| 79 | + To disable and enable extensions when you can deploy a VM with this property: |
| 80 | + |
| 81 | + ``` |
| 82 | + "osProfile": { |
| 83 | + "allowExtensionOperations": false |
| 84 | + }, |
| 85 | + ``` |
| 86 | + |
| 87 | +## Next steps |
| 88 | + |
| 89 | +Please refer to [Other base system changes since 18.04 LTS - Python 3 by default](https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default) for additional information. |
0 commit comments