Was trying to associate some data collection rules in Azure and the cmdlet kept throwing up this unhelpful error:
1 |
Exception type: ErrorResponseCommonV2Exception, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseCommonV2Exception: Operation returned an invalid status code 'BadRequest' at Microsoft.Azure.Management.Monitor.DataCollectionRuleAssociationsOperations.<CreateWithHttpMessagesAsync>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.Monitor.DataCollectionRuleAssociationsOperationsExtensions.<CreateAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Management.Monitor.DataCollectionRuleAssociationsOperationsExtensions.Create(IDataCollectionRuleAssociationsOperations operations, String resourceUri, String associationName, DataCollectionRuleAssociationProxyOnlyResource body) at Microsoft.Azure.Commands.Insights.DataCollectionRules.NewAzureRmDataCollectionRuleAssociationCommand.ProcessRecordInternalByDataCollectionRuleId() at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null |
After a bit of trial and error I figured out the issue. The association name shouldn’t contain spaces etc. I was doing -AssociationName "blah blah"
while it should have been -AssociationName "blah-blah"
.
Could have just told me that! š