Getting error and warning while executing runbook automation account

Monalisa 60 Reputation points
2024-07-01T08:21:39.7566667+00:00

We are using kusto query with powershell in Azure automation account. We are getting below error and warning while executing runbook. It will generate csv with kusto query result and sent mail to recipients . We are getting even though getting below error but with no content in csv file

Error

Search-AzGraph : { "error": { "code": "BadRequest", "message": "Please provide below info when asking for support: timestamp = 2024-07-01T07:48:05.0426324Z, correlationId = b79f5212-4466-432a-a3dc-587ec28de8c0.", "details": [ { "code": "InvalidQuery", "message": "Query is invalid. Please refer to the documentation for the Azure Resource Graph service and fix the error before retrying." }, { "code": "ParserFailure", "message": "ParserFailure", "line": 17, "characterPositionInLine": 5, "token": "." } ] } } At line:112 char:12 + $Details = Search-AzGraph -Query $Query -First 1000 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Search-AzGraph], ErrorResponseException + FullyQualifiedErrorId : BadRequest,Microsoft.Azure.Commands.ResourceGraph.Cmdlets.SearchAzureRmGraph

Warning

TenantId 'xxxxxxxxxxxxxx' contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext. To override which subscription Connect-AzAccount selects by default, use Update-AzConfig -DefaultSubscriptionForLogin 00000000-0000-0000-0000-000000000000. Go to https://go.microsoft.com/fwlink/?linkid=2200610 for more information.

Note: I have run the kusto query alone in Azure resource graph . Its giving expected results.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,187 questions
0 comments No comments
{count} votes

Accepted answer
  1. Abdul 2,360 Reputation points Microsoft Vendor
    2024-07-03T05:46:18.3933333+00:00

    Hi @Monalisa,

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer. They can only accept answers by others, Summarized and posted the solution that you shared, request you to Accept the answer, it will benefit the community find the answers quickly.

    Scenario:

    The kusto query script is invalid.

    Issue:

    TenantId 'xxxxxxxxxxxxxx' contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext. To override which subscription, Connect-AzAccount selects by default, use Update-AzConfig -DefaultSubscriptionForLogin 00000000-0000-0000-0000-000000000000. 

    Things Tried:

    Running the Kusto query independently in the Azure Resource Graph confirmed that it is returning the expected results

    Shared by @Monalisa

    Resolution: Since the warning indicates multiple subscriptions, explicitly set the correct subscription context using the Set-AzContext command. This ensures that the right subscription is used for the query execution.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Monalisa 60 Reputation points
    2024-07-01T10:03:04.0966667+00:00

    This issue is resolved. Kindly ignore this case

    0 comments No comments