Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/azure-cli/azure/cli/command_modules/appconfig/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from knack.prompting import NoTTYException, prompt_y_n
from knack.util import CLIError
from azure.appconfiguration import AzureAppConfigurationClient
from azure.mgmt.appconfiguration.models import ErrorException
from azure.core.exceptions import HttpResponseError

from ._client_factory import cf_configstore
from ._constants import HttpHeaders
Expand All @@ -30,7 +30,7 @@ def construct_connection_string(cmd, config_store_name):
for entry in access_keys:
if not entry.read_only:
return connection_string_template.format(endpoint, entry.id, entry.value)
except ErrorException as ex:
except HttpResponseError as ex:
raise CLIError('Failed to get access keys for the App Configuration "{}". Make sure that the account that logged in has sufficient permissions to access the App Configuration store.\n{}'.format(config_store_name, str(ex)))

raise CLIError('Cannot find a read write access key for the App Configuration {}'.format(config_store_name))
Expand All @@ -44,7 +44,7 @@ def resolve_store_metadata(cmd, config_store_name):
if store.name.lower() == config_store_name.lower():
# Id has a fixed structure /subscriptions/subscriptionName/resourceGroups/groupName/providers/providerName/configurationStores/storeName"
return store.id.split('/')[4], store.endpoint
except ErrorException as ex:
except HttpResponseError as ex:
raise CLIError("Failed to get the list of App Configuration stores for the current user. Make sure that the account that logged in has sufficient permissions to access the App Configuration store.\n{}".format(str(ex)))

raise CLIError("Failed to find the App Configuration store '{}'.".format(config_store_name))
Expand Down
59 changes: 19 additions & 40 deletions src/azure-cli/azure/cli/command_modules/appconfig/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
ResourceIdentity,
UserIdentity,
EncryptionProperties,
KeyVaultProperties)
KeyVaultProperties,
RegenerateKeyParameters)

from ._utils import resolve_store_metadata, user_confirmation

Expand Down Expand Up @@ -45,21 +46,19 @@ def create_configstore(client,
sku=Sku(name=sku),
public_network_access=public_network_access)

return client.create(resource_group_name, name, configstore_params)
return client.begin_create(resource_group_name, name, configstore_params)


def delete_configstore(cmd, client, name, resource_group_name=None, yes=False):
if resource_group_name is None:
resource_group_name, _ = resolve_store_metadata(cmd, name)
confirmation_message = "Are you sure you want to delete the App Configuration: {}".format(
name)
confirmation_message = "Are you sure you want to delete the App Configuration: {}".format(name)
user_confirmation(confirmation_message, yes)
return client.delete(resource_group_name, name)
return client.begin_delete(resource_group_name, name)


def list_configstore(client, resource_group_name=None):
response = client.list() if resource_group_name is None else client.list_by_resource_group(
resource_group_name)
response = client.list() if resource_group_name is None else client.list_by_resource_group(resource_group_name)
return response


Expand Down Expand Up @@ -100,9 +99,9 @@ def update_configstore(cmd,

update_params.encryption = EncryptionProperties(key_vault_properties=key_vault_properties)

return client.update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=update_params)
return client.begin_update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=update_params)


def assign_managed_identity(cmd, client, name, resource_group_name=None, identities=None):
Expand Down Expand Up @@ -131,9 +130,9 @@ def assign_managed_identity(cmd, client, name, resource_group_name=None, identit
managed_identities = ResourceIdentity(type=','.join(identity_types) if identity_types else 'None',
user_assigned_identities=user_assigned_identities if user_assigned_identities else None)

client.update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=ConfigurationStoreUpdateParameters(identity=managed_identities))
client.begin_update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=ConfigurationStoreUpdateParameters(identity=managed_identities))

# Due to a bug in RP https://msazure.visualstudio.com/Azure%20AppConfig/_workitems/edit/6017040
# It client.update does not return the updated identities.
Expand Down Expand Up @@ -172,32 +171,24 @@ def remove_managed_identity(cmd, client, name, resource_group_name=None, identit
managed_identities = ResourceIdentity(type=','.join(identity_types) if identity_types else 'None',
user_assigned_identities=user_assigned_identities if user_assigned_identities else None)

client.update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=ConfigurationStoreUpdateParameters(identity=managed_identities))
client.begin_update(resource_group_name=resource_group_name,
config_store_name=name,
config_store_update_parameters=ConfigurationStoreUpdateParameters(identity=managed_identities))


def show_managed_identity(cmd, client, name, resource_group_name=None):
config_store = show_configstore(cmd, client, name, resource_group_name)

return config_store.identity if config_store.identity else {}


def list_credential(cmd, client, name, resource_group_name=None):
resource_group_name, endpoint = resolve_store_metadata(cmd, name)
credentials = client.list_keys(resource_group_name, name)
augmented_credentials = []

for credentail in credentials:
augmented_credential = __convert_api_key_to_json(credentail, endpoint)
augmented_credentials.append(augmented_credential)
return augmented_credentials
resource_group_name, _ = resolve_store_metadata(cmd, name)
return client.list_keys(resource_group_name, name)


def regenerate_credential(cmd, client, name, id_, resource_group_name=None):
resource_group_name, endpoint = resolve_store_metadata(cmd, name)
credentail = client.regenerate_key(resource_group_name, name, id_)
return __convert_api_key_to_json(credentail, endpoint)
resource_group_name, _ = resolve_store_metadata(cmd, name)
return client.regenerate_key(resource_group_name, name, RegenerateKeyParameters(id=id_))


def __get_resource_identity(assign_identity):
Expand Down Expand Up @@ -236,15 +227,3 @@ def __validate_cmk(encryption_key_name=None,
else:
if any(arg is not None for arg in [encryption_key_vault, encryption_key_version, identity_client_id]):
logger.warning("Removing the customer encryption key. Key vault related arguments are ignored.")


def __convert_api_key_to_json(credentail, endpoint):
augmented_credential = {}
augmented_credential['id'] = credentail.id
augmented_credential['name'] = credentail.name
augmented_credential['value'] = credentail.value
augmented_credential['lastModified'] = credentail.last_modified
augmented_credential['readOnly'] = credentail.read_only
augmented_credential['connectionString'] = 'Endpoint=' + \
endpoint + ';Id=' + credentail.id + ';Secret=' + credentail.value
return augmented_credential
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Dec 11 12:04:49 China Standard Time 2020
#Mon Dec 28 11:55:37 Pacific Standard Time 2020
Color=Red
Region=West US
feature-management.FalseFeature=false
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading