|
| 1 | +--- |
| 2 | +title: Considerations for using VM extensions in Python 3-enabled Linux 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 systems |
| 21 | + |
| 22 | +## Summary |
| 23 | + |
| 24 | +> ![NOTE] |
| 25 | +> 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**. |
| 26 | +> |
| 27 | +> 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 Microsoft products, update with **Python 3.8** support, you should discontinue use of Python 2.x. |
| 28 | +
|
| 29 | +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: |
| 30 | + |
| 31 | +- You are still working on Python 3.x support in their roadmap |
| 32 | +- You use the legacy `/usr/bin/python` entrypoint |
| 33 | + |
| 34 | +Linux distribution users who have transitioned to **Python 3.x** must remove the legacy `/usr/bin/python` entrypoint before attempting to deploy those extensions to their VMs. Otherwise, the extension deployment might fail. |
| 35 | + |
| 36 | +- Endorsed Linux distributions that are affected include **Ubuntu Server 20.04 LTS** and **Ubuntu Pro 20.04 LTS**. |
| 37 | + |
| 38 | +- Affected VM Extensions include **Azure Disk Encryption**, **Log Analytics**, **VM Access** (used for Password Reset), and **Guest Diagnostics** (used for additional performance counters). |
| 39 | + |
| 40 | +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. |
| 41 | + |
| 42 | +## Resolution |
| 43 | + |
| 44 | +These are general recommendations to consider before deploying extensions in the known-affected scenarios described previously in the Summary: |
| 45 | + |
| 46 | +1. Before deploying the extension, reinstate the `/usr/bin/python` symlink by installing vendor-provided packages. |
| 47 | + |
| 48 | + - For example, for **Python 2.7**, use: `sudo apt update && sudo apt install python-is-python2` |
| 49 | + |
| 50 | +2. If you’ve already deployed an instance with 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. |
| 51 | + |
| 52 | +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. |
| 53 | + |
| 54 | + For example, for Python 2.7: |
| 55 | + |
| 56 | + ``` |
| 57 | + # create cloud-init config |
| 58 | + cat > cloudinitConfig.json <<EOF |
| 59 | + #cloud-config |
| 60 | + package_update: true |
| 61 | + |
| 62 | + runcmd: |
| 63 | + - sudo apt update |
| 64 | + - sudo apt install python-is-python2 |
| 65 | + EOF |
| 66 | + |
| 67 | + # create VM |
| 68 | + az vm create \ |
| 69 | + --resource-group <resourceGroupName> \ |
| 70 | + --name <vmName> \ |
| 71 | + --image <Ubuntu 20.04 Image URN> \ |
| 72 | + --admin-username azadmin \ |
| 73 | + --ssh-key-value "<sshPubKey>" \ |
| 74 | + --custom-data ./cloudinitConfig.json |
| 75 | + ``` |
| 76 | + |
| 77 | +4. If your organization’s policy administrators determine that extensions shouldn’t be deployed in VMs, you can disable extension support at provisioning time: |
| 78 | + |
| 79 | + - REST API |
| 80 | + |
| 81 | + To disable and enable extensions when you can deploy a VM with this property: |
| 82 | + |
| 83 | + ``` |
| 84 | + "osProfile": { |
| 85 | + "allowExtensionOperations": false |
| 86 | + }, |
| 87 | + ``` |
| 88 | + |
| 89 | + See [VMs without WALinuxAgent](https://github.com/Azure/WALinuxAgent/wiki/VMs-without-WALinuxAgent#disable-extension-operations) for additional details. |
| 90 | + |
| 91 | +## More Information |
| 92 | + |
| 93 | +[Other base system changes since 18.04 LTS - Python 3 by default](https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default) |
0 commit comments