Skip to content

ApplicationInsightsManagementClient.web_test.create_or_update: "System.NullReferenceException" #40094

@mortatella-ktm

Description

@mortatella-ktm
  • Package Name: azure-mgmt-applicationinsights
  • Package Version: 4.1.0
  • Operating System: Windows
  • Python Version: 3.9.18

Describe the bug
When creating a new web_test the underlying API returns a " System.NullReferenceException" response without further details

File "[]\azure\mgmt\applicationinsights\v2022_06_15\operations\_web_tests_operations.py", line 538, in create_or_update
    raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (InternalServerError) Object reference not set to an instance of an object.
Code: InternalServerError
Message: Object reference not set to an instance of an object.
Inner error: {
    "trace": [
        "System.NullReferenceException"
    ]
}

To Reproduce
Steps to reproduce the behavior:

from azure.mgmt import applicationinsights

from azure.mgmt.applicationinsights.models import (
    WebTest,
    WebTestKind,
    WebTestPropertiesRequest,
    WebTestGeolocation,
    WebTestPropertiesValidationRules,
)

# from azure.identity.aio import DefaultAzureCredential
from azure import identity

HIDDEN_LINK_TAG = "hidden-link:/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/microsoft.insights/components/{resource_name}"

resource_info_dict = {
    'subscription_id':'XXX',
    'resource_group':'XXX',
    'resource_name':'XXX'
}

test_name = "test_name_dummy"
app_name = "dummy_name"
url = "https://example.com"
hidden_link = HIDDEN_LINK_TAG.format(**resource_info_dict)

web_test = WebTest(
    kind=WebTestKind.STANDARD,
    request=WebTestPropertiesRequest(
        request_url=url,
        http_verb="GET",
        parse_dependent_requests=False,
    ),
    web_test_name=test_name,
    description=f"Ping {app_name}",
    enabled=True,
    synthetic_monitor_id=test_name,
    frequency=900,
    timeout=30,
    retry_enabled=False,
    location="westeurope",
    validation_rules=WebTestPropertiesValidationRules(
        ssl_check=False,
        expected_http_status_code=200,
        content_validation=None,
        ignore_http_status_code=False,
        ssl_cert_remaining_lifetime_check=None,
    ),
    tags={hidden_link: "Resource"},
    locations=[WebTestGeolocation(location="emea-nl-ams-azr")],
)

credentials = identity.DefaultAzureCredential()
client = applicationinsights.ApplicationInsightsManagementClient(
        subscription_id='###', credential=credentials
)

result = client.web_tests.create_or_update(
    resource_group_name=resource_info_dict['resource_group'],
    web_test_name=web_test.web_test_name,
    web_test_definition=web_test,
)

Expected behavior
Creating the web test or return some more informative error message

Metadata

Metadata

Assignees

Labels

MgmtThis issue is related to a management-plane library.Monitor - ApplicationInsightsbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions