Onboarding Azure Arc VM fails: can't install Azure Connected Machine Agent - azure

I'd like to add an offsite Windows VM to Azure Arc for health monitoring. The VM is hosted by Vultr and runs Windows Server 2016 Standard Build 14393.
However, installing AzureConnectedMachineAgent.msi on the target VM fails with error code 1603. Installation log also contains this error:
Start-Service : Service 'Guest Configuration Extension service
WixQuietExec64: (ExtensionService)' cannot be started due to the following error: Cannot start
WixQuietExec64: service ExtensionService on computer '.'.
WixQuietExec64: At C:\Program Files\AzureConnectedMachineAgent\ExtensionService\GC\Modules\Exte
WixQuietExec64: nsionService\ServiceHelper.psm1:367 char:5
Any suggestions on how to fix this?

You may Check if the user with which you are logged into the VM have
sufficient permissions to start a system service
If you find the following in the
%ProgramData%\AzureConnectedMachineAgent\Log\himds.log or in installation logs :
time="2021-02-11T08:39:38-08:00" level=error msg="Cannot open event source: Azure Hybrid Instance Metadata Service."
You can verify the permissions by collecting the following registry
key from an impacted server.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Eventlog\Application\CustomS
Mitigation can be to grant the permission to write to the
SECURITY_SERVICE_RID S-1-5-6 which would grant the required
permissions to the himds service account.
https://learn.microsoft.com/en-us/windows/win32/secauthz/well-known-sids.
If the registry key does NOT exist on the impacted VM, then this
resolution will NOT apply as there will be a separate root cause such
as AV interference.
If the root cause is not found here ,then a procmon trace needs to be
taken to analyze the root cause for the msi not being able to start a
service.
( In case a procmon trace has to be analyzed , please open an MS
Support ticket)

To get support for Windows Agent and extensions in Azure, the Windows
Agent on the Windows VM must be later than or equal to version
2.7.41491.911. However the cause for the failure of agent installation is different in this case.
You may also want to check %programdata%\ext_mgr_logs\gc_ext_telemetry.txt log which must have had an entry something like this :
<GCLOG>........ Not starting Extension Service since machine is an Azure VM</GCLOG>
Cause:
This can happen while attempting to install the agent on an Azure VM.This is an unsupported production scenario.One Should not be installing this agent on an Azure VM as it conflicts with the Azure Guest Agent and interferes with Azure VM management.
If one wishes to use an Azure VM simply for testing purposes then
they can follow the below document for guidance
https://learn.microsoft.com/en-us/azure/azure-arc/servers/plan-evaluate-on-azure-virtual-machine

Related

Unable to configure Azure Insights on Azure VM running Windows

I am attempting to configure the Log Analytics agent for Insights on my Azure VM running Windows. When I attempt to deploy the monitoring configuration, the DependencyAgentWindows VM extension fails to install. I have the same solution working on a similar VM and am stumped on what the issue is for the failing VM.
{"code":"DeploymentFailed","message":"At least one resource deployment> operation failed. Please list deployment operations for details.> Please see https://aka.ms/DeployOperations for usage
details.","details":"code":"VMExtensionHandlerNonTransientError","message":"The
handler for VM extension type
'Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows'
has reported terminal failure for VM extension
'DependencyAgentWindows' with error message: 'Install failed for
plugin (name:
Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows,
version 9.10.16.22650) with exception Command
C:\Packages\Plugins\Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows\9.10.16.22650\scripts\RunPs1.cmd
of Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows
has exited with Exit code: 52'.\r\n \r\n'Install handler failed for
the extension. More information on troubleshooting is available at
https://aka.ms/VMExtensionDependencyAgentWindowsTroubleshoot'"}]}
I have tried to deploying the Monitoring Configuration and installing the DepencyAgentWindows VM Extension through the Portal and through PowerShell. I am expecting the DepencyAgentWindows VM Extension to install properly and be able to enable Insights successfully.
I tried to reproduce same in my environment I got the results successfully like below.
This issue usually occurs if network connectivity issues preventing the plugin from being downloaded and if the extension won't work properly if the vm agent is failing to report a status to the Azure platform..
To resolve this issue:
Try to delete if any other extension is already exists in your vm
In virtual machine -> extension -> uninstall
In monitor -> virtual machine -> configure insights -> enable -> monitoring configuration -> configure
When I try to deploy, it deployed successfully like below:
If still issue persists, try to uninstall the vm and Redeploy it and also check the MsDoc to know the supported operating system versions.

Azure - Enable Backup on VM with Windows Server 2019 Core server, D4s_v3 sku, is failing with code BMSUserErrorContainerObjectNotFound

Azure VM Details :
OS : Windows Server 2019 Datacenter Core
Size: Standard D4s v3 (4 vcpus, 16 GiB memory)
Location: Australia East
VM generation: V1
Agent status: Ready
Agent version: 2.7.41491.1010
Azure disk encryption: Not Enabled
Extensions already installed :
DependencyAgentWindows
IaaSAntimalware
MDE.Windows
MicrosoftMonitoringAgent
Have an existing recovery services vault with 10s of other VMs getting backed up.
Trying to enable the backup from Azure Portal for this VM ( From the VM Blade > Operations > Backup ) but it's failing with the following error code:
I have tried it multiple times.
Provisioning state: Failed
Duration: 1 minute 3 seconds
Status: Conflict
{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
"details": [
{
"code": "BMSUserErrorContainerObjectNotFound",
"message": "Item not found"
}
]
}
All the information on troubleshooting backup relates issues # https://learn.microsoft.com/en-us/azure/backup/backup-azure-vms-troubleshoot talk about After the "Enable Backup" step.
I have also tried to enable the backup using azure cli:
az backup protection enable-for-vm --vm "/subscriptions/xxx/resourceGroups/yyy/providers/Microsoft.Compute/virtualMachines/vm_name" -v vaultname -g vault_resourcegroup -p backuppolicy_name
It throws the following error:
The specified Azure Virtual Machine Not Found. Possible causes are
1. VM does not exist
2. The VM name or the Service name needs to be case sensitive
3. VM is already Protected with same or other Vault.
Please Unprotect VM first and then try to protect it again.
Please contact Microsoft for further assistance.
None of the Point 1,2 or 3 are true.
VM exists, the name is used as shown in the portal, no other VM protection service is in use.
Note: I have faced this issue a few days back on another subscription, but luckily no one was yet using that VM, so I destroyed and re-deployed the VM, and the error went away.
I can't do the same for this VM as it's already in use.
Any help/guidance will be appreciated.
Seems like a portal error or the VM is not able to communicate with Azure Platform. I would suggest you try the "Reapply" feature to update the platform status.
[Snippet of Reapply in Azure Porta][1]
Else, you can try initiating a backup from the "Recovery Services vaults" blade and add the VM to it.
The solution was to contact Microsoft support. Their engineer after some analysis ( aka to and fro, screenshots exchange over email..etc) replied with:
I check from the backend and notice that the VM status is not in synchronize state. I’ve requested the VM engineer xxxxx resync the VM from the backend. Please try to reenable the VM backup again in the Azure portal recovery service Vault page. If you encounter the same issue, please try to configure the VM backup in the Azure Virtual Machine Panel page and let me know the results. Thanks!
After this when I attempted to enable the backup it worked.
So for anyone who faces this problem, it looks like the only option is to get in touch with MS Support.

Azure Devops: installing a Windows Service

I am trying to automate installing windows service using Azure DevOps pipeline. I installed Windows Service Manager from here: https://marketplace.visualstudio.com/items?itemName=MDSolutions.WindowsServiceManagerWindowsServiceManager and added it to the pipeline as a task. The windows service should be installed on the virtual machine where the pipeline is, so I provided "LocalSystem" as Run As Username, and nothing for password. The service was not installed with the following error:
Service ' (MyServiceName)' cannot be created due to the following error: The account name is invalid or does not exist, or the password is invalid for the account name specified
I tried also the credentials I use to get to the virtual machine, but it gave the same error. How can this be solved?
Added:
The service can be installed without problems using installutil.
Azure Devops: installing a Windows Service
You could try to use deployment groups to test, if you are using the private agent:
As the document state:
Service Name - The name of the Windows Service installed on the Deployment Group Target.
You could also refer to the similar thread for some more details.

Azure DevOps Manage IIS task deploy fails due to insufficent permissions yet account is in local admin group

After a successful build using a hosted VS2017 agent, I'm trying to deploy on-prem using an local hosted agent which was setup using a domain account which should have sufficient permissions as it is in the local admin group. As I was digging around on this issue elsewhere, one user re-installed their agent using NTATHORITY\SYSTEM and it worked.
I d'ont really need to create or stop\start the website, just deploy the recent build artifact.
What permissions should I check or should I use another task?
019-04-06T21:03:10.3898646Z ERROR ( message:Configuration error
2019-04-06T21:03:10.3899503Z
2019-04-06T21:03:10.3899791Z Filename: redirection.config
2019-04-06T21:03:10.3900026Z 2019-04-06T21:03:10.3900293Z Line
Number: 0 2019-04-06T21:03:10.3900530Z 2019-04-06T21:03:10.3900852Z
Description: Cannot read configuration file due to insufficient
permissions 2019-04-06T21:03:10.3901076Z 2019-04-06T21:03:10.3901333Z
. ) 2019-04-06T21:03:10.8135484Z ##[error]Process 'appcmd.exe' exited
with code '5'.
An agent is running under a user. The error means that your user doesn't have permissions to read/modify the redirection.config file that is necessary to manage IIS.
You have multiple options to solve this.
Change the user were the agent is running under. In example: NTATHORITY\SYSTEM
Give permissions to the user were your agent is running under to the folder C:\Windows\System32\inetsrv\config. If you want to create app pools or websites etc, modify permissions are of course needed.
When we install Azure agent as a service(In Windows, search for 'Services' and look for something like Azure Pipelines Agent..), by default it is logged on as 'Network Service'. Change it to 'Local System' and the pipeline should be able to run IIS related tasks/commands.

Install service in windows azure

I would like to know that is there any way to install the windows service on Azure environment? Or is there any alternate way of doing the same?
If I understand the question correctly what you need in Azure is a Worker Role, similar question on Stackoverflow: What's the concept of *worker role* in Windows Azure cloud?
Check out the this blog post 'Migrating Windows Service to Azure Worker Role'
http://blogs.msdn.com/b/joseph_fultz/archive/2010/04/02/migrating-windows-service-to-azure-worker-role-image-conversion-example-using-storage.aspx
Also look at the Windows Azure Training Kit for code & usage sample for Worker Roles in Azure
http://www.microsoft.com/download/en/details.aspx?id=8396
HTH
Another potential option is to use StartUp tasks to install a windows service in either a Web or a Worker Role.
Here is an MSDN article - although it seems a little short on the details.
How to Define Startup Tasks for a Role
Basically you will need to be sure that the installer is copied during the deployment and create a cmd file to execute the installer. Then add a Startup task element to the service definition XML file.
Couple of things to add along with the other answers:
You can install Services with Web or Worker Role through the Startup Task
Alternatively you can also run a process with elevated privilege through the Task Scheduler
Here are the steps to install a windows service on VM running Windows Server 2012 R2:
start your VM in Windows Azure Console and connect to it with Remote Desktop Connector
map your storage as a new drive in your VM:
net use z: \mystorage.file.core.windows.net\endoint /u:myusername verylongkeythatendswith==
Storage key can be found in your Azure Management Console -> Storages -> Manage Access Keys
copy all the necessary installation files to the mapped storage (copy&paste)
copy nssm to a local drive (not z: as it uses MAFS file system and that cannot be accessed with low-level windows API commands)
Create a .bat file with the following entries
set username=xxx
set password=yyy
call d:\nssm install "My service"
"%programfiles%\PathToService\myservice.exe" "-p 8677"
d:\nssm set "My service" ObjectName "%username%" "%password%"
sc failure "My service" actions= restart/60000/restart/60000/restart/60000 reset= 240
d:\nssm start "My service"
Username and password should be the ones you used to create the VM.
run the script. The service should be visible in your services list.
Enjoy!
PS : I used NSSM to simplify the service deployment.

Resources