-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[App Config] az appconfig create/update/network-security-perimeter-configuration: Add NSP support
#33301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
[App Config] az appconfig create/update/network-security-perimeter-configuration: Add NSP support
#33301
Changes from all commits
ed60f1e
7ef0550
3ef7251
f2f8848
047afb0
c949e54
d905e87
40681b4
176166c
083570e
81249e6
f56aae6
0ecdfd2
59ccf00
58312fd
cb2f089
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| from azure.cli.core.commands.progress import IndeterminateStandardOut | ||
| from azure.cli.core.util import user_confirmation | ||
| from azure.core.exceptions import ResourceNotFoundError | ||
| from azure.cli.core.azclierror import RequiredArgumentMissingError | ||
| from azure.cli.core.azclierror import MutuallyExclusiveArgumentError, RequiredArgumentMissingError | ||
| from azure.mgmt.appconfiguration.models import (ConfigurationStoreUpdateParameters, | ||
| ConfigurationStore, | ||
| Sku, | ||
|
|
@@ -48,6 +48,7 @@ def create_configstore(cmd, # pylint: disable=too-many-locals | |
| tags=None, | ||
| assign_identity=None, | ||
| enable_public_network=None, | ||
| public_network_access=None, | ||
| disable_local_auth=None, | ||
| retention_days=None, | ||
| enable_purge_protection=None, | ||
|
|
@@ -62,7 +63,10 @@ def create_configstore(cmd, # pylint: disable=too-many-locals | |
| if assign_identity is not None and not assign_identity: | ||
| assign_identity = [SYSTEM_ASSIGNED_IDENTITY] | ||
|
|
||
| public_network_access = None | ||
| if public_network_access is not None and enable_public_network is not None: | ||
| raise MutuallyExclusiveArgumentError("Cannot specify both '--enable-public-network' and '--public-network-access'. " | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is more of an internal error. We've escaped the context of the CLI user's arguments. The 'public' error is the one in "Only one of |
||
| "Please use '--public-network-access' as '--enable-public-network' has been deprecated.") | ||
|
|
||
| if enable_public_network is not None: | ||
| public_network_access = PublicNetworkAccess.ENABLED if enable_public_network else PublicNetworkAccess.DISABLED | ||
|
|
||
|
|
@@ -193,6 +197,7 @@ def update_configstore(cmd, # pylint: disable=too-many-locals | |
| encryption_key_version=None, | ||
| identity_client_id=None, | ||
| enable_public_network=None, | ||
| public_network_access=None, | ||
| disable_local_auth=None, | ||
| enable_purge_protection=None, | ||
| arm_auth_mode=None, | ||
|
|
@@ -204,7 +209,10 @@ def update_configstore(cmd, # pylint: disable=too-many-locals | |
| if resource_group_name is None: | ||
| resource_group_name, _ = resolve_store_metadata(cmd, name) | ||
|
|
||
| public_network_access = None | ||
| if public_network_access is not None and enable_public_network is not None: | ||
| raise MutuallyExclusiveArgumentError("Cannot specify both '--enable-public-network' and '--public-network-access'. " | ||
| "Please use '--public-network-access' as '--enable-public-network' has been deprecated.") | ||
|
|
||
| if enable_public_network is not None: | ||
| public_network_access = PublicNetworkAccess.ENABLED if enable_public_network else PublicNetworkAccess.DISABLED | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||
| # -------------------------------------------------------------------------------------------- | ||||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||||
| # -------------------------------------------------------------------------------------------- | ||||
|
|
||||
| # pylint: disable=line-too-long | ||||
|
|
||||
| from azure.core.exceptions import ResourceNotFoundError | ||||
|
|
||||
| from ._utils import resolve_store_metadata | ||||
|
|
||||
|
|
||||
| def list_nsp_configurations(cmd, client, store_name, resource_group_name=None): | ||||
| if resource_group_name is None: | ||||
| resource_group_name, _ = resolve_store_metadata(cmd, store_name) | ||||
| return client.list_by_configuration_store(resource_group_name=resource_group_name, config_store_name=store_name) | ||||
|
|
||||
|
|
||||
| def show_nsp_configuration(cmd, client, store_name, name, resource_group_name=None): | ||||
| if resource_group_name is None: | ||||
| resource_group_name, _ = resolve_store_metadata(cmd, store_name) | ||||
| try: | ||||
| return client.get( | ||||
| resource_group_name=resource_group_name, | ||||
| config_store_name=store_name, | ||||
| network_security_perimeter_configuration_name=name | ||||
| ) | ||||
| except ResourceNotFoundError: | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice that when we do a show for a configuration store, we let this error go unhandled (link). So is error handling missing there, or is this unnecessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the resource is missing, the SDK raises ResourceNotFoundError with the message "Operation returned an invalid status 'Not Found'", which doesn't tell the user which resource was not found its a bit generic. We catch and re-raise with a message that includes the NSP configuration name, so the error is actionable. For a store, we catch it here in the resolve_store_metadata function
Thoughts?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. That makes sense then. Thanks. |
||||
| raise ResourceNotFoundError( | ||||
| "The network security perimeter configuration '{}' for App Configuration '{}' was not found.".format( | ||||
| name, store_name)) | ||||
|
|
||||
|
|
||||
| def reconcile_nsp_configuration(cmd, client, store_name, name, resource_group_name=None): | ||||
| if resource_group_name is None: | ||||
| resource_group_name, _ = resolve_store_metadata(cmd, store_name) | ||||
| try: | ||||
| return client.begin_reconcile( | ||||
| resource_group_name=resource_group_name, | ||||
| config_store_name=store_name, | ||||
| network_security_perimeter_configuration_name=name | ||||
| ) | ||||
| except ResourceNotFoundError: | ||||
| raise ResourceNotFoundError( | ||||
| "The network security perimeter configuration '{}' for App Configuration '{}' was not found.".format( | ||||
| name, store_name)) | ||||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every other command seems to have
table_transformerspecified. How come nsp doesn't need it?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! The
table_transformercontrols how a command's output is rendered when the user passes -o table. We should add it for nsp as well. I am not sure what fields to have in the nsp table_transformer. There are a couple of fields which are nested together within the NSP configuration response. https://review.learn.microsoft.com/en-us/rest/api/documentation-preview/network-security-perimeter-configurations?view=azure-rest-preview&branch=preview%2FAzure%2Fazure-rest-api-specs%2Fpr%2F38653%2Fbuild%2F6138442%2Fattempt%2F1 .The second part has the table_transformer specified.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a table_transformer format for nsp. Please let me know what other fields we should have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you paste the output with the nsp transformer in use? I can't access your image for some reason.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it to load. It does look like a lot of columns. After some thought I think maybe we can reduce it to the below set of columns:
perimeter id
profile name
access mode
access rules version
diagnostic setting version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been updated :)