Microsoft.Insights/webtests - Bicep, ARM template & Terraform AzAPI reference (2023)

  • Article
  • Latest
  • 2022-06-15
  • 2020-10-05-preview
  • 2018-05-01-preview
  • 2015-05-01

Bicep resource definition

The webtests resource type can be deployed to:

  • Resource groups - See resource group deployment commands

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Insights/webtests resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Insights/webtests@2022-06-15' = { name: 'string' location: 'string' tags: { tagName1: 'tagValue1' tagName2: 'tagValue2' } kind: 'string' properties: { Configuration: { WebTest: 'string' } Description: 'string' Enabled: bool Frequency: int Kind: 'string' Locations: [ { Id: 'string' } ] Name: 'string' Request: { FollowRedirects: bool Headers: [ { key: 'string' value: 'string' } ] HttpVerb: 'string' ParseDependentRequests: bool RequestBody: 'string' RequestUrl: 'string' } RetryEnabled: bool SyntheticMonitorId: 'string' Timeout: int ValidationRules: { ContentValidation: { ContentMatch: 'string' IgnoreCase: bool PassIfTextFound: bool } ExpectedHttpStatusCode: int IgnoreHttpsStatusCode: bool SSLCertRemainingLifetimeCheck: int SSLCheck: bool } }}

Property values

webtests

NameDescriptionValue
nameThe resource namestring (required)
locationResource locationstring (required)
tagsResource tagsDictionary of tag names and values. See Tags in templates
kindThe kind of WebTest that this web test watches. Choices are ping, multistep and standard.'multistep'
'ping'
'standard'
propertiesMetadata describing a web test for an Azure resource.WebTestProperties

WebTestProperties

NameDescriptionValue
ConfigurationAn XML configuration specification for a WebTest.WebTestPropertiesConfiguration
DescriptionUser defined description for this WebTest.string
EnabledIs the test actively being monitored.bool
FrequencyInterval in seconds between test runs for this WebTest. Default value is 300.int
KindThe kind of web test this is, valid choices are ping, multistep and standard.'multistep'
'ping'
'standard' (required)
LocationsA list of where to physically run the tests from to give global coverage for accessibility of your application.WebTestGeolocation[] (required)
NameUser defined name if this WebTest.string (required)
RequestThe collection of request propertiesWebTestPropertiesRequest
RetryEnabledAllow for retries should this WebTest fail.bool
SyntheticMonitorIdUnique ID of this WebTest. This is typically the same value as the Name field.string (required)
TimeoutSeconds until this WebTest will timeout and fail. Default value is 30.int
ValidationRulesThe collection of validation rule propertiesWebTestPropertiesValidationRules

WebTestPropertiesConfiguration

NameDescriptionValue
WebTestThe XML specification of a WebTest to run against an application.string

WebTestGeolocation

NameDescriptionValue
IdLocation ID for the WebTest to run from.string

WebTestPropertiesRequest

NameDescriptionValue
FollowRedirectsFollow redirects for this web test.bool
HeadersList of headers and their values to add to the WebTest call.HeaderField[]
HttpVerbHttp verb to use for this web test.string
ParseDependentRequestsParse Dependent request for this WebTest.bool
RequestBodyBase64 encoded string body to send with this web test.string
RequestUrlUrl location to test.string

HeaderField

NameDescriptionValue
keyThe name of the header.string
valueThe value of the header.string

WebTestPropertiesValidationRules

NameDescriptionValue
ContentValidationThe collection of content validation propertiesWebTestPropertiesValidationRulesContentValidation
ExpectedHttpStatusCodeValidate that the WebTest returns the http status code provided.int
IgnoreHttpsStatusCodeWhen set, validation will ignore the status code.bool
SSLCertRemainingLifetimeCheckA number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true.int
SSLCheckChecks to see if the SSL cert is still valid.bool

WebTestPropertiesValidationRulesContentValidation

NameDescriptionValue
ContentMatchContent to look for in the return of the WebTest. Must not be null or empty.string
IgnoreCaseWhen set, this value makes the ContentMatch validation case insensitive.bool
PassIfTextFoundWhen true, validation will pass if there is a match for the ContentMatch string. If false, validation will fail if there is a matchbool

Quickstart templates

The following quickstart templates deploy this resource type.

(Video) You really can manage ALL Microsoft Azure services and features with Terraform | OD107

TemplateDescription
Dynamic Web Test Creation

Microsoft.Insights/webtests - Bicep, ARM template & Terraform AzAPI reference (1)

Create any number of App Insights web (ping) tests.
Metric alert rule for an availability test

Microsoft.Insights/webtests - Bicep, ARM template & Terraform AzAPI reference (2)

This template creates an Application Insights availability test along with a metric alert rule that monitors it.
(Video) How To Create Availability Tests for Azure App Service in Bicep 💪

ARM template resource definition

The webtests resource type can be deployed to:

  • Resource groups - See resource group deployment commands

For a list of changed properties in each API version, see change log.

(Video) Deploy a Web Application with Azure Resource Management Templates

Resource format

To create a Microsoft.Insights/webtests resource, add the following JSON to your template.

{ "type": "Microsoft.Insights/webtests", "apiVersion": "2022-06-15", "name": "string", "location": "string", "tags": { "tagName1": "tagValue1", "tagName2": "tagValue2" }, "kind": "string", "properties": { "Configuration": { "WebTest": "string" }, "Description": "string", "Enabled": "bool", "Frequency": "int", "Kind": "string", "Locations": [ { "Id": "string" } ], "Name": "string", "Request": { "FollowRedirects": "bool", "Headers": [ { "key": "string", "value": "string" } ], "HttpVerb": "string", "ParseDependentRequests": "bool", "RequestBody": "string", "RequestUrl": "string" }, "RetryEnabled": "bool", "SyntheticMonitorId": "string", "Timeout": "int", "ValidationRules": { "ContentValidation": { "ContentMatch": "string", "IgnoreCase": "bool", "PassIfTextFound": "bool" }, "ExpectedHttpStatusCode": "int", "IgnoreHttpsStatusCode": "bool", "SSLCertRemainingLifetimeCheck": "int", "SSLCheck": "bool" } }}

Property values

webtests

NameDescriptionValue
typeThe resource type'Microsoft.Insights/webtests'
apiVersionThe resource api version'2022-06-15'
nameThe resource namestring (required)
locationResource locationstring (required)
tagsResource tagsDictionary of tag names and values. See Tags in templates
kindThe kind of WebTest that this web test watches. Choices are ping, multistep and standard.'multistep'
'ping'
'standard'
propertiesMetadata describing a web test for an Azure resource.WebTestProperties

WebTestProperties

NameDescriptionValue
ConfigurationAn XML configuration specification for a WebTest.WebTestPropertiesConfiguration
DescriptionUser defined description for this WebTest.string
EnabledIs the test actively being monitored.bool
FrequencyInterval in seconds between test runs for this WebTest. Default value is 300.int
KindThe kind of web test this is, valid choices are ping, multistep and standard.'multistep'
'ping'
'standard' (required)
LocationsA list of where to physically run the tests from to give global coverage for accessibility of your application.WebTestGeolocation[] (required)
NameUser defined name if this WebTest.string (required)
RequestThe collection of request propertiesWebTestPropertiesRequest
RetryEnabledAllow for retries should this WebTest fail.bool
SyntheticMonitorIdUnique ID of this WebTest. This is typically the same value as the Name field.string (required)
TimeoutSeconds until this WebTest will timeout and fail. Default value is 30.int
ValidationRulesThe collection of validation rule propertiesWebTestPropertiesValidationRules

WebTestPropertiesConfiguration

NameDescriptionValue
WebTestThe XML specification of a WebTest to run against an application.string

WebTestGeolocation

NameDescriptionValue
IdLocation ID for the WebTest to run from.string

WebTestPropertiesRequest

NameDescriptionValue
FollowRedirectsFollow redirects for this web test.bool
HeadersList of headers and their values to add to the WebTest call.HeaderField[]
HttpVerbHttp verb to use for this web test.string
ParseDependentRequestsParse Dependent request for this WebTest.bool
RequestBodyBase64 encoded string body to send with this web test.string
RequestUrlUrl location to test.string

HeaderField

NameDescriptionValue
keyThe name of the header.string
valueThe value of the header.string

WebTestPropertiesValidationRules

NameDescriptionValue
ContentValidationThe collection of content validation propertiesWebTestPropertiesValidationRulesContentValidation
ExpectedHttpStatusCodeValidate that the WebTest returns the http status code provided.int
IgnoreHttpsStatusCodeWhen set, validation will ignore the status code.bool
SSLCertRemainingLifetimeCheckA number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true.int
SSLCheckChecks to see if the SSL cert is still valid.bool

WebTestPropertiesValidationRulesContentValidation

NameDescriptionValue
ContentMatchContent to look for in the return of the WebTest. Must not be null or empty.string
IgnoreCaseWhen set, this value makes the ContentMatch validation case insensitive.bool
PassIfTextFoundWhen true, validation will pass if there is a match for the ContentMatch string. If false, validation will fail if there is a matchbool

Quickstart templates

The following quickstart templates deploy this resource type.

TemplateDescription
Dynamic Web Test Creation

Microsoft.Insights/webtests - Bicep, ARM template & Terraform AzAPI reference (3)

Create any number of App Insights web (ping) tests.
Metric alert rule for an availability test

Microsoft.Insights/webtests - Bicep, ARM template & Terraform AzAPI reference (4)

This template creates an Application Insights availability test along with a metric alert rule that monitors it.

Terraform (AzAPI provider) resource definition

The webtests resource type can be deployed to:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Insights/webtests resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" { type = "Microsoft.Insights/webtests@2022-06-15" name = "string" location = "string" parent_id = "string" tags = { tagName1 = "tagValue1" tagName2 = "tagValue2" } body = jsonencode({ properties = { Configuration = { WebTest = "string" } Description = "string" Enabled = bool Frequency = int Kind = "string" Locations = [ { Id = "string" } ] Name = "string" Request = { FollowRedirects = bool Headers = [ { key = "string" value = "string" } ] HttpVerb = "string" ParseDependentRequests = bool RequestBody = "string" RequestUrl = "string" } RetryEnabled = bool SyntheticMonitorId = "string" Timeout = int ValidationRules = { ContentValidation = { ContentMatch = "string" IgnoreCase = bool PassIfTextFound = bool } ExpectedHttpStatusCode = int IgnoreHttpsStatusCode = bool SSLCertRemainingLifetimeCheck = int SSLCheck = bool } } kind = "string" })}

Property values

webtests

NameDescriptionValue
typeThe resource type"Microsoft.Insights/webtests@2022-06-15"
nameThe resource namestring (required)
locationResource locationstring (required)
parent_idTo deploy to a resource group, use the ID of that resource group.string (required)
tagsResource tagsDictionary of tag names and values.
kindThe kind of WebTest that this web test watches. Choices are ping, multistep and standard."multistep"
"ping"
"standard"
propertiesMetadata describing a web test for an Azure resource.WebTestProperties

WebTestProperties

NameDescriptionValue
ConfigurationAn XML configuration specification for a WebTest.WebTestPropertiesConfiguration
DescriptionUser defined description for this WebTest.string
EnabledIs the test actively being monitored.bool
FrequencyInterval in seconds between test runs for this WebTest. Default value is 300.int
KindThe kind of web test this is, valid choices are ping, multistep and standard."multistep"
"ping"
"standard" (required)
LocationsA list of where to physically run the tests from to give global coverage for accessibility of your application.WebTestGeolocation[] (required)
NameUser defined name if this WebTest.string (required)
RequestThe collection of request propertiesWebTestPropertiesRequest
RetryEnabledAllow for retries should this WebTest fail.bool
SyntheticMonitorIdUnique ID of this WebTest. This is typically the same value as the Name field.string (required)
TimeoutSeconds until this WebTest will timeout and fail. Default value is 30.int
ValidationRulesThe collection of validation rule propertiesWebTestPropertiesValidationRules

WebTestPropertiesConfiguration

NameDescriptionValue
WebTestThe XML specification of a WebTest to run against an application.string

WebTestGeolocation

NameDescriptionValue
IdLocation ID for the WebTest to run from.string

WebTestPropertiesRequest

NameDescriptionValue
FollowRedirectsFollow redirects for this web test.bool
HeadersList of headers and their values to add to the WebTest call.HeaderField[]
HttpVerbHttp verb to use for this web test.string
ParseDependentRequestsParse Dependent request for this WebTest.bool
RequestBodyBase64 encoded string body to send with this web test.string
RequestUrlUrl location to test.string

HeaderField

NameDescriptionValue
keyThe name of the header.string
valueThe value of the header.string

WebTestPropertiesValidationRules

NameDescriptionValue
ContentValidationThe collection of content validation propertiesWebTestPropertiesValidationRulesContentValidation
ExpectedHttpStatusCodeValidate that the WebTest returns the http status code provided.int
IgnoreHttpsStatusCodeWhen set, validation will ignore the status code.bool
SSLCertRemainingLifetimeCheckA number of days to check still remain before the the existing SSL cert expires. Value must be positive and the SSLCheck must be set to true.int
SSLCheckChecks to see if the SSL cert is still valid.bool

WebTestPropertiesValidationRulesContentValidation

NameDescriptionValue
ContentMatchContent to look for in the return of the WebTest. Must not be null or empty.string
IgnoreCaseWhen set, this value makes the ContentMatch validation case insensitive.bool
PassIfTextFoundWhen true, validation will pass if there is a match for the ContentMatch string. If false, validation will fail if there is a matchbool
(Video) How to use AKS Observability with bicep, GitHub actions and Azure Managed Grafana

FAQs

What is the difference between ARM template and terraform? ›

To choose between the two, consider your project's needs and features. For instance, Terraform stores credentials in plain text in the state file, while ARM templates do not have a state file. If you are an engineer concerned with securing your configuration files, you might choose ARM templates over Terraform.

How do you reference a resource in Bicep? ›

To reference an existing resource that isn't deployed in your current Bicep file, declare the resource with the existing keyword. Use the existing keyword when you're deploying a resource that needs to get a value from an existing resource. You access the existing resource's properties through its symbolic name.

What is reference in ARM template? ›

Reference() Function Explained With Examples - ARM Template. In this post, we will review reference() function which often comes handy when working with ARM templates. This function allows to retrieving runtime state of a resource which contains useful information such as URIs, names or other settings.

What is Bicep ARM template? ›

Bicep is a transparent abstraction over ARM template JSON and doesn't lose any of the JSON template capabilities. During deployment, the Bicep CLI converts a Bicep file into ARM template JSON. Resource types, API versions, and properties that are valid in an ARM template are valid in a Bicep file.

Is Terraform better than Bicep? ›

Bicep is Azure-specific and not designed to work with other cloud services. If your goal is to automate deployments to any of the following environments, Terraform is likely the better option: Virtualization environments. Multicloud scenarios - such as Azure and other cloud(s)

Why use Terraform over ARM templates? ›

ARM templates are all created in one file. By contrast, Terraform evaluates every resource in the directory with a . tf extension -- and will do so for every command that runs the resource, which enables IT admins to break up resources into separate files to ease parsing.

How do you convert an arm template to a Bicep? ›

Decompile using the Bicep Playground

You can decompile your ARM template into a Bicep template. To convert your template, you only need to select the “Decompile” option and upload your ARM template, and you will get the Bicep file. Another option you have is to convert your Bicep template into an ARM template.

How do you deploy a Bicep template vs code? ›

Deploy the Bicep file

Right-click the Bicep file inside the VSCode, and then select Deploy Bicep file. From the Select Resource Group listbox on the top, select Create new Resource Group.

How do you deploy Bicep templates? ›

For more information, see file in template spec.
  1. Copy the following Bicep module and save it to your computer as storage. ...
  2. Replace <subscriptionId> in the module. ...
  3. Use Azure PowerShell or Azure CLI to create a new resource group for the storage account. ...
  4. Deploy the template spec with Azure PowerShell or Azure CLI.
Jun 23, 2023

When should I use an ARM template? ›

What are ARM templates, and why should I use them? ARM templates are JSON files where you define what you want to deploy to Azure. Templates help you implement an infrastructure-as-code solution for Azure. Your organization can repeatedly and reliably deploy the required infrastructure to different environments.

What is the difference between Azure ARM and Bicep? ›

The first noticeable difference is that the bicep template is only half the size of that of ARM. Firstly, the parameters are more compact as the type, name, and default value can all be written in a single line. Secondly, Bicep is smart enough to determine if resources depend on each other.

What is the difference between ARM Bicep and JSON? ›

The Bicep ternary operator is the equivalent to the if function in an ARM template JSON, not the condition property. The ternary syntax has to evaluate to one value or the other. If the condition is false in the preceding samples, Bicep outputs a hostname with an empty string, but JSON outputs no values.

What is the alternative to Bicep in Azure? ›

On Azure, three of the most obvious choices for Infrastructure as Code (IaC) are Bicep, Terraform, and Pulumi. Bicep is Microsoft's own domain-specific language, whereas Terraform is the open-source tool that is cloud agnostic.

Can we call ARM template from Terraform? ›

Deploying ARM Templates with Terraform

HashiCorp Terraform has a resource called azurerm_resource_group_template_deployment for the AzureRM provider. This resource allows you to deploy an ARM Template through HashiCorp Terraform.

Can we convert ARM template to Terraform? ›

There's a tool called aztfy which can create terraform code from an existing environment, but there are currently no tools to transform ARM and CLI to native terraform.

What is the difference between Terraform and cloud formation template? ›

What is the difference between Terraform and CloudFormation? Terraform and CloudFormation are both infrastructure-as-code (IaC) tools. CloudFormation is developed by AWS and only manages AWS resources. Terraform is developed by HashiCorp and can manage resources across a wide range of cloud vendors.

What is the difference between Terraform and bicep? ›

It's a cloud-agnostic tool, meaning it can manage resources across Azure, AWS, Google Cloud, and others. This makes Terraform a great choice for multi-cloud environments. Bicep, however, is Azure-specific. It's deeply integrated with Azure and provides a first-class experience for Azure resource management.

References

Top Articles
Latest Posts
Article information

Author: Kerri Lueilwitz

Last Updated: 08/30/2023

Views: 6000

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Kerri Lueilwitz

Birthday: 1992-10-31

Address: Suite 878 3699 Chantelle Roads, Colebury, NC 68599

Phone: +6111989609516

Job: Chief Farming Manager

Hobby: Mycology, Stone skipping, Dowsing, Whittling, Taxidermy, Sand art, Roller skating

Introduction: My name is Kerri Lueilwitz, I am a courageous, gentle, quaint, thankful, outstanding, brave, vast person who loves writing and wants to share my knowledge and understanding with you.