Reputation: 313
I am trying to create a template for App Insights web availability tests. I am using bicep, and this is my template:
param location string = resourceGroup().location
param pingText string = ''
param appInsightsResource string
param tests array
resource tests_0_name 'Microsoft.Insights/webtests@2015-05-01' = {
name: tests[0].name
location: location
tags: {
'hidden-link:${appInsightsResource}': 'Resource'
}
properties: {
Name: tests[0].name
Description: tests[0].description
Enabled: true
Frequency: tests[0].frequency_secs
Timeout: tests[0].timeout_secs
Kind: 'ping'
Locations: tests[0].locations
Configuration: {
WebTest: '<WebTest Name="${tests[0].name}" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="120" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale=""> <Items> <Request Method="GET" Version="1.1" Url="${tests[0].url}" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="${tests[0].expected}" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" /> </Items> <ValidationRules> <ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidationRuleFindText, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Find Text" Description="Verifies the existence of the specified text in the response." Level="High" ExecutionOrder="BeforeDependents"> <RuleParameters> <RuleParameter Name="FindText" Value="${pingText}" /> <RuleParameter Name="IgnoreCase" Value="False" /> <RuleParameter Name="UseRegularExpression" Value="False" /> <RuleParameter Name="PassIfTextFound" Value="True" /> </RuleParameters> </ValidationRule> </ValidationRules> </WebTest>'
}
SyntheticMonitorId: tests[0].name
}
}
and also a parameters file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsResource": {
"value": "myappinsight"
},
"tests": {
"value": [
{
"name": "5121",
"url": "http://www.microsoft.com",
"expected": 200,
"frequency_secs": 300,
"timeout_secs": 30,
"failedLocationCount": 1,
"description": "a description for test1",
"guid": "5122",
"locations": [
{
"Id": "us-il-ch1-azr"
}
]
},
{
"name": "1242",
"url": "http://www.microsoft.com",
"expected": 404,
"frequency_secs": 300,
"timeout_secs": 30,
"failedLocationCount": 1,
"description": "a description for test3",
"guid": "5211",
"locations": [
{
"Id": "us-il-ch1-azr"
}
]
}
]
}
}
}
The problem is that, when I create this I get an error {"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"A single 'hidden-link' tag pointing to an existing AI component is required. Found none."}]} "A single 'hidden-link' tag pointing to an existing AI component is required. Found none. As you can see, I have a tag with hidden link, but Azure points to my tests, which I suppose do not have this tags, I don't know how to add them or what do to to make this work.
Upvotes: 1
Views: 518
Reputation: 1198
The special char -
was no problem on my side but may be you must ensure that ${appInsightsResource} is the Id and not the name of the AppInsights resource. (That was my mistake)
So me following works:
param applicationInsightsName string
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}
resource symbolicname 'Microsoft.Insights/webtests@2022-06-15' = {
name: testName
location: location
tags: {
'hidden-link:${applicationInsights.id}': 'Resource'
}
kind: 'ping'
properties: {
//...
Upvotes: 1
Reputation: 4786
While adding tags to resources we have some limitations. I have noticed that in your Bicep template you are using Special Character -
.
hidden-link:${appInsightsResource}'
Some Special Characters are not supported those are <
, >
, %
, &
, \
, ?
, /
,-
.
resource tests_0_name 'Microsoft.Insights/webtests@2015-05-01' = {
name: tests[0].name
location: location
tags: {
# While adding tags remove the special charactor
'hiddenlink:${appInsightsResource}': 'Resource'
}
Upvotes: 0