Closed rafaeldnferreira closed 1 year ago
This should be a general issue with cmdlets generated by Autorest.powershell. I will transfer it to the proper repo.
@rafaeldnferreira Our current design is to use new- cmdlets only for resource creating. You should need to use update- for update, which is mapped to the patch API instead of PUT API.
Hi @dolauli ,
I understand your statement, but this isn't what has been reflected in the generated module/documentation:
It makes a promise to create or update the resource:
Creates or updates a packet core control plane.
The Updated commands was only generated to update the Tags Update-AzMobileNetworkPacketCoreControlPlane (which is the only operation supported by PATCH
in our Swagger definition)
Updates packet core control planes tags.
Our Swagger clearly exposes that PUT
is a Create/Replace verb.
There are two potential solutions here and I would like you/autorest.powershell team to advise on what's best: Fix the New cmdlet to behave as it is documented or change the Update to be based on the PUT action and not PATCH.
Update-AzMobileNetworkPacketCoreControlPlane can only update the tag is a limitation of the service, and service team should provide full functional patch API actually. PUT is 'replace' (full update) as you said. And we used to generate a set-* cmdlet for PUT to do the full update. But finally we remove it, since feedback from customers feel it is not easy to use. And users have to provide the information they do not need to update when using it. Yes, get->put is a potential solution, which actually should be supported by service in the patch API. To support it in client-side will have some limitations as below.
Last, you still can use create-* cmdlet for full update(replace) though we do not recommend users to do that. Since we pull description from swagger to generate docs, that explains why it is 'Creates or updates a packet core control plane.'. If you think the docs is an problem, we could try to correct it from our side.
Hi @dolauli , thanks for the details,
1) Your statement around PATCH
doesn't hold true - there's no business case for our service to provide a synchronous PATCH operation other than the updates of tags, I'm assuming that will be the case for other services that deploy/manage resources beyond the cloud borders (Edge/Arc).
2) We fully understand the limitations on doing GET / PUT, but that's exactly the approach the AZ Cli is doing and it is an acceptable behaviour for our use case:
rafael@RAFAELFERREIRA:~$ az mobile-network pccp update -n site01 -g tp-rg-2022-11-01 --ue-mtu 1290 --debug
cli.knack.cli: Command arguments: ['mobile-network', 'pccp', 'update', '-n', 'site01', '-g', 'tp-rg-2022-11-01', '--ue-mtu', '1290', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fc7882b51b0>, <function OutputProducer.on_global_arguments at 0x7fc7881afc70>, <function CLIQuery.on_global_arguments at 0x7fc7881f8ee0>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'mobile-network': ['azext_mobile_network']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: mobile-network 0.071 10 23 /home/rafael/.azure/cliextensions/mobile-network
cli.azure.cli.core: Total (1) 0.071 10 23
cli.azure.cli.core: Loaded 10 groups, 23 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : mobile-network pccp update
cli.azure.cli.core: Command table: mobile-network pccp update
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fc786dc85e0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/rafael/.azure/commands/2023-02-15.08-56-15.mobile-network_pccp_update.917.log'.
az_command_data_logger: command args: mobile-network pccp update -n {} -g {} --ue-mtu {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fc786de52d0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fc786e0fbe0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fc786e0fd00>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fc7881afd00>, <function CLIQuery.handle_query_parameter at 0x7fc7881f8f70>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fc786e0fc70>]
az_command_data_logger: extension name: mobile-network
az_command_data_logger: extension version: 0.1.0
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/rafael/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/rafael/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: openid_config = {'token_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/v2.0', 'request_uri_parameter_supported': False, 'userinfo_endpoint': 'https://graph.microsoft.com/oidc/userinfo', 'authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/authorize', 'device_authorization_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/devicecode', 'http_logout_supported': True, 'frontchannel_logout_supported': True, 'end_session_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/logout', 'claims_supported': ['sub', 'iss', 'cloud_instance_name', 'cloud_instance_host_name', 'cloud_graph_host_name', 'msgraph_host', 'aud', 'exp', 'iat', 'auth_time', 'acr', 'nonce', 'preferred_username', 'name', 'tid', 'ver', 'at_hash', 'c_hash', 'email'], 'kerberos_endpoint': 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/kerberos', 'tenant_region_scope': 'WW', 'cloud_instance_name': 'microsoftonline.com', 'cloud_graph_host_name': 'graph.windows.net', 'msgraph_host': 'graph.microsoft.com', 'rbac_url': 'https://pas.windows.net'}
msal.application: Broker enabled? False
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 1deb19c2-a20b-4261-8d66-8e7aa984aba2
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01?api-version=2022-11-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '9a8ba9c6-ad0e-11ed-bd4b-00155d48856b'
cli.azure.cli.core.sdk.policies: 'CommandName': 'mobile-network pccp update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -g --ue-mtu --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.45.0 (DEB) (AAZ) azsdk-python-core/1.24.0 Python/3.10.8 (Linux-5.15.79.1-microsoft-standard-WSL2-x86_64-with-glibc2.35)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01?api-version=2022-11-01 HTTP/1.1" 200 None
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Transfer-Encoding': 'chunked'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Content-Encoding': 'gzip'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'ETag': '"950068f7-0000-0100-0000-6390d3c10000"'
cli.azure.cli.core.sdk.policies: 'Vary': 'Accept-Encoding'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '11999'
cli.azure.cli.core.sdk.policies: 'x-ms-providerhub-traffic': 'True'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': 'afb7643b-1f02-4e16-8139-b4eea1010ea3'
cli.azure.cli.core.sdk.policies: 'x-ms-build-version': '1.0.1'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '6f762e55-fe5d-4459-a1c1-a6bcbdbf5181'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'UKSOUTH:20230215T085615Z:6f762e55-fe5d-4459-a1c1-a6bcbdbf5181'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 15 Feb 2023 08:56:14 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"id":"/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01","name":"site01","type":"microsoft.mobilenetwork/packetcorecontrolplanes","location":"eastus","systemData":{"createdBy":"thomaspretty@microsoft.com","createdByType":"User","createdAt":"2022-12-07T17:56:03.3362824Z","lastModifiedBy":"thomaspretty@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-12-07T17:56:03.3362824Z"},"identity":{"type":"None"},"properties":{"provisioningState":"Succeeded","sites":[{"id":"/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/mobileNetworks/mn/sites/site01"}],"platform":{"type":"BaseVM"},"coreNetworkTechnology":"5GC","version":"pmn-2211-0-3","controlPlaneAccessInterface":{"ipv4Address":"1.1.1.1","ipv4Subnet":"1.1.1.1/24","ipv4Gateway":"1.1.1.1"},"sku":"G1","localDiagnosticsAccess":{"authenticationType":"AAD","httpsServerCertificate":{"certificateUrl":""}}}}
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01?api-version=2022-11-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '578'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '9a8ba9c6-ad0e-11ed-bd4b-00155d48856b'
cli.azure.cli.core.sdk.policies: 'CommandName': 'mobile-network pccp update'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -g --ue-mtu --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.45.0 (DEB) (AAZ) azsdk-python-core/1.24.0 Python/3.10.8 (Linux-5.15.79.1-microsoft-standard-WSL2-x86_64-with-glibc2.35)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"identity": {"type": "None"}, "location": "eastus", "properties": {"controlPlaneAccessInterface": {"ipv4Address": "1.1.1.1", "ipv4Gateway": "1.1.1.1", "ipv4Subnet": "1.1.1.1/24"}, "coreNetworkTechnology": "5GC", "localDiagnosticsAccess": {"authenticationType": "AAD", "httpsServerCertificate": {"certificateUrl": ""}}, "platform": {"type": "BaseVM"}, "sites": [{"id": "/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/mobileNetworks/mn/sites/site01"}], "sku": "G1", "ueMtu": 1290, "version": "pmn-2211-0-3"}}
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01?api-version=2022-11-01 HTTP/1.1" 201 1046
cli.azure.cli.core.sdk.policies: Response status: 201
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '1046'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'ETag': '"1e00fc0c-0000-0100-0000-63ec9e310000"'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '1199'
cli.azure.cli.core.sdk.policies: 'x-ms-providerhub-traffic': 'True'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '4a370b39-479d-4af4-a541-69c09c31d1e3'
cli.azure.cli.core.sdk.policies: 'x-ms-build-version': '1.0.1'
cli.azure.cli.core.sdk.policies: 'Azure-AsyncOperation': 'https://management.azure.com/providers/Microsoft.MobileNetwork/locations/EASTUS/operationStatuses/890c4efc-a278-4a99-ac36-ab4265431f54*63494DF6D3AA20D4FF3A3E74CF53CC65AD46231E140FFC964937F20B0BC24319?api-version=2022-11-01'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '5f112770-98de-4685-b715-32d071772844'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'UKSOUTH:20230215T085618Z:5f112770-98de-4685-b715-32d071772844'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 15 Feb 2023 08:56:17 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"id":"/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/site01","name":"site01","type":"microsoft.mobilenetwork/packetcorecontrolplanes","location":"eastus","systemData":{"createdBy":"thomaspretty@microsoft.com","createdByType":"User","createdAt":"2022-12-07T17:56:03.3362824Z","lastModifiedBy":"rafaelda@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2023-02-15T08:56:16.1707097Z"},"identity":{"type":"None"},"properties":{"provisioningState":"Accepted","controlPlaneAccessInterface":{"ipv4Address":"1.1.1.1","ipv4Gateway":"1.1.1.1","ipv4Subnet":"1.1.1.1/24"},"coreNetworkTechnology":"5GC","localDiagnosticsAccess":{"authenticationType":"AAD","httpsServerCertificate":{"certificateUrl":""}},"platform":{"type":"BaseVM"},"sites":[{"id":"/subscriptions/53c7a82a-bf93-4419-8236-6c242a03f675/resourceGroups/tp-rg-2022-11-01/providers/Microsoft.MobileNetwork/mobileNetworks/mn/sites/site01"}],"sku":"G1","ueMtu":1290,"version":"pmn-2211-0-3"}}
Currently, you will need to support it through customization. And here is an example for get->put.
Thanks @dolauli I've raised the discussion to the attention of the other stake holders in our original service onboarding mail chain, I believe you are on it.
Close it since workaround is provided.
Description
Take for reference New-AzMobileNetworkPacketCoreControlPlane:
I've created my resource;
Now I will perform an update, so first I perform a Get:
$pccp = Get-AzMobileNetworkPacketCoreControlPlane -ResourceGroup rf4-mobile-network -Name site-msi-cert
Then I update a single property:
$pccp.ControlPlaneAccessInterfaceIpv4Address = "10.0.2.6"
Finally, I send (what I expect to be the Update instruction because the resource already exists):
The problem here is that a single PUT instruction has been generated (see Debug output) instead of a GET, followed by a merge with the properties I've just supplied, hence the Update fails.
Issue script & Debug output
Environment data
Module versions
Error output