Skip to content

[Sample Issue] UpdateExpressRouteCrossConnection #5765

Open
@cmek

Description

@cmek

Link to sample

https://learn.microsoft.com/en-us/rest/api/expressroute/express-route-cross-connections/create-or-update?view=rest-expressroute-2024-05-01&tabs=Python#request-body

Library name and version

azure-mgmt-network 28.1.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

Using the code provided in the documentation:

response = client.express_route_cross_connections.begin_create_or_update(
        resource_group_name="CrossConnection-SiliconValley",
        cross_connection_name="<circuitServiceKey>",
        parameters={"properties": {"serviceProviderProvisioningState": "NotProvisioned"}},
    ).result()

results in the following error:

raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (LocationRequired) The location property is required for this definition.
Code: LocationRequired
Message: The location property is required for this definition.

Turns out the code needs "location" and expressRouteCircuit parameters to work correctly, so a working example would look like this:



response = client.express_route_cross_connections.begin_create_or_update(
        resource_group_name="CrossConnection-SiliconValley",
        cross_connection_name="<circuitServiceKey>",
        parameters={"serviceProviderProvisioningState": "NotProvisioned",
                                 "location": expressroute.location,
                                 "expressRouteCircuit": {
                                     "id": expressroute.express_route_circuit.id
                                   }},
    ).result()

where expressroute is the ExpressRouteCrossConnect object being updated as returned from express_route_cross_connections.get() method

Expected behavior

expected behavior is for the example code to work (ie, not return any errors from the API) and result in the serviceProviderProvisioningState being updated to the given value.

Actual behavior

throws an error:

raise HttpResponseError(response=response, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: (LocationRequired) The location property is required for this definition.
Code: LocationRequired
Message: The location property is required for this definition.

Reproduction Steps

  1. copy and paste the python code sample provided in the documentation
  2. run it
  3. see it return an error

Environment

python 3.12 running on Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions