Azure / Azure/ArcEnabledServersGroupPolicy
EnableAzureArc script does not detect when himds service is stopped, performs complete reinstall
- Dominant language
- PowerShell
- Stars
- 17
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
If the EnableAzureArc.ps1 script is run when the 'Azure Hybrid Instance Metadata Service' (himds) is Stopped, it fails to detect that state, and instead attempts to reinstall the service.
See log from C:\temp\AzureArcOnboarding.log below:
```
[2024-04-23][13:44:01] INFO =========================================
[2024-04-23][13:44:01] INFO Starting Azure Arc Onboarding process ...
[2024-04-23][13:44:01] INFO Sources full path: \\ReportServerFQDN\ArcRemoteShare\AzureArcDeploy
[2024-04-23][13:44:01] INFO Logging network full path: \\ReportServerFQDN\ArcRemoteShare\AzureArcLogging
[2024-04-23][13:44:02] INFO Machine has Framework version 4.8.3761, this is supported
[2024-04-23][13:44:02] INFO Machine has PowerShell version version 5, this is supported
[2024-04-23][13:44:06] INFO Machine is not an Azure VM. Continuing the onboarding process
[2024-04-23][13:44:06] INFO Machine has the Hybrid Instance Metadata Service already installed ...
[2024-04-23][13:44:06] INFO Checking Local Agent version for updates ...
[2024-04-23][13:46:52] WARNING New Agent version found in network share folder: , local version is . Executing update ...
[2024-04-23][13:46:54] INFO Updating Azure Connected Machine Agent
[2024-04-23][13:47:01] INFO Azure Connected Machine Agent updated. The operation completed successfully.
[2024-04-23][13:49:41] INFO Azure Connected Machine Agent Version is now
[2024-04-23][13:49:43] ERROR There was an error when trying to get agent status: System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it [::1]:40342
at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
```
Suggest:
- The script should detect when the himds service is stopped, and check to see if starting it resolves any issues
- The Update-ArcAgentVersion function should check the result of Get-ArcAgentstatus, and only update if it returned a genuine version number instead of erroring out
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.