If the Azure VMAgent is not provisioned or installed on an Azure VM, you will not be able to use any extensions with that VM
The error sound like VM Agent is not installed in the VM
So, the first step is to install VMAgent and Enable VM Extensions: Check the status of the agent
$vm = Get-AzVM -ResourceGroupName <RG name> -Name <vm name>
$vm.OSProfile.WindowsConfiguration.ProvisionVMAgent
$vm.OSProfile.AllowExtensionOperations
If you see the, result of final command as 'False', you need to download and install VMAgent in the VM. Manual installation may be necessary when you create a custom VM image that is deployed to Azure. To manually install the Windows VM Agent, download the VM Agent installer and select the latest release
It is important to update the AllowExtensionOperations option after manually installing the VMAgent on a VM that was deployed from image without ProvisionVMAgent enable using the following scripts
$vm.OSProfile.AllowExtensionOperations = $true
$vm | Update-AzVM
Once the option is enabled you should now be able to install and use extensions on the Azure VM.
----------
--please don't forget to upvote
and Accept as answer
if the reply is helpful--