Skip to content
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

[Cosmos DB] az cosmosdb create: add --key-uri to support adding key vault encryption information #12417

Merged
merged 8 commits into from
Mar 5, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def load_arguments(self, _):

with self.argument_context('cosmosdb create') as c:
c.argument('account_name', completer=None)
c.argument('key_uri', help="The URI of the key vault", is_preview=True)

for scope in ['cosmosdb create', 'cosmosdb update']:
with self.argument_context(scope) as c:
Expand Down
6 changes: 4 additions & 2 deletions src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def cli_cosmosdb_create(cmd, client,
enable_virtual_network=None,
virtual_network_rules=None,
enable_multiple_write_locations=None,
disable_key_based_metadata_write_access=None):
disable_key_based_metadata_write_access=None,
key_uri=None):
"""Create a new Azure Cosmos DB database account."""
consistency_policy = None
if default_consistency_level is not None:
Expand Down Expand Up @@ -117,7 +118,8 @@ def cli_cosmosdb_create(cmd, client,
capabilities=capabilities,
virtual_network_rules=virtual_network_rules,
enable_multiple_write_locations=enable_multiple_write_locations,
disable_key_based_metadata_write_access=disable_key_based_metadata_write_access)
disable_key_based_metadata_write_access=disable_key_based_metadata_write_access,
key_vault_key_uri=key_uri)

async_docdb_create = client.create_or_update(resource_group_name, account_name, params)
docdb_account = async_docdb_create.result()
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.

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.

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.

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.

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.

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.

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.

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.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -926,3 +926,25 @@ def test_cosmosdb_table_resource_throughput(self, resource_group):

db_througput_update = self.cmd('az cosmosdb table throughput update -g {rg} -a {acc} -n {tb_name} --throughput {tp2}').get_output_in_json()
assert db_througput_update["resource"]["throughput"] == tp2

@ResourceGroupPreparer(name_prefix='cli_test_cosmosdb_key_vault_key_uri')
def test_cosmosdb_key_vault_key_uri(self, resource_group):
kv_name = self.create_random_name(prefix='cli', length=15)
key_name = self.create_random_name(prefix='cli', length=15)
key_uri = "https://{}.vault.azure.net/keys/{}".format(kv_name, key_name)

self.kwargs.update({
'acc': self.create_random_name(prefix='cli', length=15),
'kv_name': kv_name,
'key_name': key_name,
'key_uri': key_uri,
'location': "eastus2"
})

self.cmd('az keyvault create --resource-group {rg} -n {kv_name} --enable-soft-delete true --enable-purge-protection true')
self.cmd('az keyvault set-policy -n {kv_name} -g {rg} --spn a232010e-820c-4083-83bb-3ace5fc29d0b --key-permissions get unwrapKey wrapKey')
self.cmd('az keyvault key create -n {key_name} --kty RSA --size 3072 --vault-name {kv_name}')

cmk_output = self.cmd('az cosmosdb create -n {acc} -g {rg} --locations regionName={location} failoverPriority=0 --key-uri {key_uri}').get_output_in_json()

assert cmk_output["keyVaultKeyUri"] == key_uri
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==3.0.0rc8
azure-mgmt-containerservice==8.1.0
azure-mgmt-cosmosdb==0.11.0
azure-mgmt-cosmosdb==0.12.0
azure-mgmt-datalake-analytics==0.2.1
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==3.0.0rc8
azure-mgmt-containerservice==8.1.0
azure-mgmt-cosmosdb==0.11.0
azure-mgmt-cosmosdb==0.12.0
azure-mgmt-datalake-analytics==0.2.1
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==3.0.0rc8
azure-mgmt-containerservice==8.1.0
azure-mgmt-cosmosdb==0.11.0
azure-mgmt-cosmosdb==0.12.0
azure-mgmt-datalake-analytics==0.2.1
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'azure-mgmt-containerinstance~=1.4',
'azure-mgmt-containerregistry~=3.0.0rc8',
'azure-mgmt-containerservice~=8.1.0',
'azure-mgmt-cosmosdb~=0.11.0',
'azure-mgmt-cosmosdb~=0.12.0',
'azure-mgmt-datalake-analytics~=0.2.1',
'azure-mgmt-datalake-store~=0.5.0',
'azure-mgmt-datamigration~=0.1.0',
Expand Down