Azure / Azure/azure-powershell
Az.StackHCI Register-AzStackHCI ignores custom resource group for Arc initialization
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
When custom resource group is specified in Register-AzureStackHCI parameter, it will likely result in error registering arc agent.
```PowerShell
Register-AzStackHCI -Region $Region -SubscriptionID $subscriptionID -ComputerName $ClusterName -GraphAccessToken $graphToken -ArmAccessToken $armToken -AccountId $id -ResourceName $ClusterName -ResourceGroupName $ResourceGroupName
```


### Issue script & Debug output
```PowerShell
AgentConnectedStatus: Disconnected, GCServiceStatus: , ExtServiceStatus: , HimdsServiceStatus:
DEBUG: powershell.exe Error: 0 :
DEBUG: Arc agent process failed to onboard machine. Process Output: time="2021-11-23T05:37:24-08:00" level=info msg="Loading AgentConfig file from: C:\\ProgramData\\AzureConnectedMachineAgent\\Config\\agentconfig.json"
time="2021-11-23T05:37:24-08:00" level=info msg="Onboarding Machine. It usually takes a few minutes to complete. Sometimes it may take longer depending on network and server load status."
time="2021-11-23T05:37:24-08:00" level=info msg="Check network connectivity to all endpoints..."
time="2021-11-23T05:37:25-08:00" level=info msg="All endpoints are available... continue onboarding"
time="2021-11-23T05:37:26-08:00" level=error msg="Failed to AzcmagentConnect ARM resource" Error="RequestCorrelationId:1c588474-df27-4cab-8440-619bd912f65e Message: Resource group 'AzSHCI-CLuster-08e3c1d9-b8f6-4af6-8186-69904d49ea76-Arc-Infra-RG' could not be found. Code: ResourceGroupNotFound httpStatusCode:404 "
time="2021-11-23T05:37:26-08:00" level=info msg="Exit Code: AZCM0042: Failed To Create Resource"
time="2021-11-23T05:37:26-08:00" level=fatal msg="RequestCorrelationId:1c588474-df27-4cab-8440-619bd912f65e Message: Resource group 'AzSHCI-CLuster-08e3c1d9-b8f6-4af6-8186-69904d49ea76-Arc-Infra-RG' could not be found. Code: ResourceGroupNotFound httpStatusCode:404 "
Enable-AzureStackHCIArcIntegration : Failed to enable Azure Stack HCI integration with Azure Arc on node AZSHCI1.
At line:41 char:2
+ Enable-AzureStackHCIArcIntegration -AgentInstallerWebLink $AgentInst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:String) [Enable-AzureStackHCIArcIntegration], Exception
+ FullyQualifiedErrorId :
AzsHciError,Microsoft.AzureStack.HCI.Billing.Management.PowerShell.EnableAzureStackHCIArcIntegration
Enable-AzureStackHCIArcIntegration : Failed to enable Azure Stack HCI integration with Azure Arc on node AZSHCI1.
At line:41 char:2
+ Enable-AzureStackHCIArcIntegration -AgentInstallerWebLink $AgentInst ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:String) [Enable-AzureStackHCIArcIntegration], Exception
+ FullyQualifiedErrorId : AzsHciError,Microsoft.AzureStack.HCI.Billing.Management.PowerShell.EnableAzureStackHCIAr
cIntegration
DEBUG: Exception in EnableAzureStackHCIArcIntegration: System.Exception: Failed to enable Azure Stack HCI integration with Azure Arc on node AZSHCI1.
at Microsoft.AzureStack.HCI.Billing.Management.PowerShell.EnableAzureStackHCIArcIntegration.ProcessRecord()
**********************
Windows PowerShell transcript end
End time: 20211123053733
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 5.1.20348.320
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.320
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```
### Module versions
```PowerShell
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.10.0 Az.StackHCI {Add-AzStackHCIVMAttestation, Disable-AzStackHCIAttestatio...
```
### Error output
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.