You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/disable-provisioning.md
+58-40Lines changed: 58 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.subservice: imaging
8
8
ms.topic: how-to
9
9
ms.workload: infrastructure
10
10
ms.custom: devx-track-azurecli
11
-
ms.date: 07/06/2020
11
+
ms.date: 04/11/2023
12
12
ms.author: danis
13
13
ms.reviewer: cynthn
14
14
---
@@ -22,6 +22,7 @@ Before removing the Linux Agent, you must understand of what VM will not be able
22
22
Azure virtual machine (VM) [extensions](../extensions/overview.md) are small applications that provide post-deployment configuration and automation tasks on Azure VMs, extensions are installed and managed by the Azure control plane. It is the job of the [Azure Linux Agent](../extensions/agent-linux.md) to process the platform extension commands and ensure the correct state of the extension inside the VM.
23
23
24
24
The Azure platform hosts many extensions that range from VM configuration, monitoring, security, and utility applications. There is a large choice of first and third-party extensions, examples of key scenarios that extensions are used for:
25
+
25
26
* Supporting first party Azure services, such as Azure Backup, Monitoring, Disk Encryption, Security, Site Replication and others.
@@ -32,19 +33,22 @@ The Azure platform hosts many extensions that range from VM configuration, monit
32
33
33
34
There are several ways to disable extension processing, depending on your needs, but before you continue, you **MUST** remove all extensions deployed to the VM, for example using the Azure CLI, you can [list](/cli/azure/vm/extension#az-vm-extension-list) and [delete](/cli/azure/vm/extension#az-vm-extension-delete):
34
35
35
-
```azurecli
36
+
```azurecli-interactive
36
37
az vm extension delete -g MyResourceGroup --vm-name MyVm -n extension_name
37
38
```
39
+
38
40
> [!Note]
39
-
>
41
+
>
40
42
> If you do not do the above, the platform will try to send the extension configuration and timeout after 40min.
41
43
42
44
### Disable at the control plane
45
+
43
46
If you are not sure whether you will need extensions in the future, you can leave the Linux Agent installed on the VM, then disable extension processing capability from the platform. This is option is available in `Microsoft.Compute` api version `2018-06-01` or higher, and does not have a dependency on the Linux Agent version installed.
44
47
45
-
```azurecli
48
+
```azurecli-interactive
46
49
az vm update -g <resourceGroup> -n <vmName> --set osProfile.allowExtensionOperations=false
47
50
```
51
+
48
52
You can easily reenable this extension processing from the platform, with the above command, but set it to 'true'.
49
53
50
54
## Remove the Linux Agent from a running VM
@@ -55,108 +59,122 @@ Ensure you have **removed** all existing extensions from the VM before, as per a
55
59
56
60
If you just remove the Linux Agent, and not the associated configuration artifacts, you can reinstall at a later date. Run one of the following, as root, to remove the Azure Linux Agent:
### Step 2: (Optional) Remove the Azure Linux Agent artifacts
74
-
> [!IMPORTANT]
81
+
82
+
> [!IMPORTANT]
75
83
>
76
84
> You can remove all associated artifacts of the Linux Agent, but this will mean you cannot reinstall it at a later date. Therefore, it is strongly recommended you consider disabling the Linux Agent first, removing the Linux Agent using the above only.
77
85
78
86
If you know you will not ever reinstall the Linux Agent again, then you can run the following:
If you have an image that already contains cloud-init, and you want to remove the Linux agent, but still provision using cloud-init, run the steps in Step 2 (and optionally Step 3) as root to remove the Azure Linux Agent and then the following will remove the cloud-init configuration and cached data, and prepare the VM to create a custom image.
105
118
106
119
```bash
107
-
cloud-init clean --logs --seed
120
+
sudo cloud-init clean --logs --seed
108
121
```
109
122
110
123
## Deprovision and create an image
124
+
111
125
The Linux Agent has the ability to clean up some of the existing image metadata, with the step "waagent -deprovision+user", however, after it has been removed, you will need to perform actions such as the below, and remove any other sensitive data from it.
112
126
113
-
- Remove all existing ssh host keys
127
+
* Remove all existing ssh host keys
114
128
115
129
```bash
116
-
rm /etc/ssh/ssh_host_*key*
130
+
sudo rm /etc/ssh/ssh_host_*key*
117
131
```
118
-
- Delete the admin account
132
+
133
+
* Delete the admin account
119
134
120
135
```bash
121
-
touch /var/run/utmp
122
-
userdel -f -r <admin_user_account>
136
+
sudo touch /var/run/utmp
137
+
sudo userdel -f -r <admin_user_account>
123
138
```
124
-
- Delete the root password
139
+
140
+
* Delete the root password
125
141
126
142
```bash
127
-
passwd -d root
143
+
sudo passwd -d root
128
144
```
129
145
130
146
Once you have completed the above, you can create the custom image using the Azure CLI.
131
147
148
+
### Create a regular managed image
132
149
133
-
**Create a regular managed image**
134
-
```azurecli
150
+
```azurecli-interactive
135
151
az vm deallocate -g <resource_group> -n <vm_name>
136
152
az vm generalize -g <resource_group> -n <vm_name>
137
153
az image create -g <resource_group> -n <image_name> --source <vm_name>
138
154
```
139
155
140
-
**Create an image version in a Azure Compute Gallery**
156
+
### Create an image version in a Azure Compute Gallery
### Creating a VM from an image that does not contain a Linux Agent
168
+
151
169
When you create the VM from the image with no Linux Agent, you need to ensure the VM deployment configuration indicates extensions are not supported on this VM.
152
170
153
-
> [!NOTE]
154
-
>
171
+
> [!NOTE]
172
+
>
155
173
> If you do not do the above, the platform will try to send the extension configuration and timeout after 40min.
156
174
157
175
To deploy the VM with extensions disabled, you can use the Azure CLI with [--enable-agent](/cli/azure/vm#az-vm-create).
0 commit comments