floopsandRoot
floopsandRoot

Reputation: 69

KQL extend column with a static link

I have a query that I am parsing using an automation runbook. When I extend a column that has a static URL reference, I get the error:

BadArgumentError- Query could not be parsed at 'https'

The extend looks like this:

| extend Body = strcat(@"<p>The following items are expiring <strong>within 30 days</strong></p>", "<p>Plan to remediate as soon as possible.</p>", "<p>If the item is no longer valid, please remove it from ", "<a href="https://portal.azure.com/#@fabrikam.com/resource/subscriptions/0000-0000-000/resourceGroups/000resourcegroup/providers/microsoft.insights/components/Fabrikam_Monitoring/availability">Application Insights</a></p>", "<p>Property: ", Name, "</p>", "<p>Expires In: ", ExpiresIn, " day(s) " "</p>")

The runbook posts to a logic app via a webhook which sends a readable output to users.

Upvotes: 1

Views: 743

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44951

We can use triple backtick (```) to qualify strings that contain single and/or double quotes.

P.S.
Also note the following:

Splicing string literals
Two or more string literals are automatically joined to form a new string literal in the query if they have nothing between them, or they're separated only by whitespace and comments.

print Name = "MyName", ExpiresIn = "7"
| extend Body = 
    strcat
    (
        "<p>The following items are expiring <strong>within 30 days</strong></p>"
        "<p>Plan to remediate as soon as possible.</p>"
        "<p>If the item is no longer valid, please remove it from "
        ```<a href="https://portal.azure.com/#@fabrikam.com/resource/subscriptions/0000-0000-000/resourceGroups/000resourcegroup/providers/microsoft.insights/components/Fabrikam_Monitoring/availability">Application Insights</a></p>```
        "<p>Property: "
        , Name
        , "</p>" 
          "<p>Expires In: " 
        ,ExpiresIn 
        ," day(s) "
         "</p>"
    )
Name ExpiresIn Body
MyName 7

The following items are expiring within 30 days

Plan to remediate as soon as possible.

If the item is no longer valid, please remove it from Application Insights

Property: MyName

Expires In: 7 day(s)

Fiddle

Upvotes: 1

Related Questions