Skip to content
Closed
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
4 changes: 4 additions & 0 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
'Directory Properties arguments must be provided.')
aadds_type = CLIArgumentType(arg_type=get_three_state_flag(), min_api='2018-11-01',
help='Enable Azure Active Directory Domain Services authentication for Azure Files')
sftp_type = CLIArgumentType(arg_type=get_three_state_flag(), min_api='2019-06-01',
help='Enable Secure File Transfer Protocol')
domain_name_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties",
help="Specify the primary domain that the AD DNS server is authoritative for. "
"Required when --enable-files-adds is set to True")
Expand Down Expand Up @@ -265,6 +267,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('min_tls_version', arg_type=get_enum_type(t_tls_version),
help='The minimum TLS version to be permitted on requests to storage. '
'The default interpretation is TLS 1.0 for this property')
c.argument('enable_sftp', sftp_type)

with self.argument_context('storage account private-endpoint-connection',
resource_type=ResourceType.MGMT_STORAGE) as c:
Expand Down Expand Up @@ -314,6 +317,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('min_tls_version', arg_type=get_enum_type(t_tls_version),
help='The minimum TLS version to be permitted on requests to storage. '
'The default interpretation is TLS 1.0 for this property')
c.argument('enable_sftp', sftp_type)

with self.argument_context('storage account update', arg_group='Customer managed key', min_api='2017-06-01') as c:
t_key_source = self.get_models('KeySource', resource_type=ResourceType.MGMT_STORAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc
encryption_key_type_for_table=None, encryption_key_type_for_queue=None,
routing_choice=None, publish_microsoft_endpoints=None, publish_internet_endpoints=None,
require_infrastructure_encryption=None, allow_blob_public_access=None,
min_tls_version=None):
min_tls_version=None, enable_sftp=None):
StorageAccountCreateParameters, Kind, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet = \
cmd.get_models('StorageAccountCreateParameters', 'Kind', 'Sku', 'CustomDomain', 'AccessTier', 'Identity',
'Encryption', 'NetworkRuleSet')
Expand Down Expand Up @@ -140,6 +140,9 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc
if min_tls_version:
params.minimum_tls_version = min_tls_version

if enable_sftp is not None:
params.is_sftp_enabled = enable_sftp

return scf.storage_accounts.begin_create(resource_group_name, account_name, params)


Expand Down Expand Up @@ -215,7 +218,7 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
domain_name=None, net_bios_domain_name=None, forest_name=None, domain_guid=None,
domain_sid=None, azure_storage_sid=None, routing_choice=None,
publish_microsoft_endpoints=None, publish_internet_endpoints=None,
allow_blob_public_access=None, min_tls_version=None):
allow_blob_public_access=None, min_tls_version=None, enable_sftp=None):
StorageAccountUpdateParameters, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet = \
cmd.get_models('StorageAccountUpdateParameters', 'Sku', 'CustomDomain', 'AccessTier', 'Identity', 'Encryption',
'NetworkRuleSet')
Expand Down Expand Up @@ -361,6 +364,8 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
params.allow_blob_public_access = allow_blob_public_access
if min_tls_version:
params.minimum_tls_version = min_tls_version
if enable_sftp is not None:
params.is_sftp_enabled = enable_sftp

return params

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,34 @@ def test_storage_update_with_min_tls(self, storage_account, resource_group):
self.cmd('az storage account update -n {} -g {} --min-tls-version TLS1_2'.format(
storage_account, resource_group), checks=[JMESPathCheck('minimumTlsVersion', 'TLS1_2')])

@api_version_constraint(ResourceType.MGMT_STORAGE, min_api='2019-06-01')
@ResourceGroupPreparer(location='eastus', name_prefix='cli_storage_account_sftp')
def test_storage_account_with_sftp(self, resource_group):
name = self.create_random_name(prefix='cli', length=24)
name1 = self.create_random_name(prefix='cli', length=24)
name2 = self.create_random_name(prefix='cli', length=24)
name3 = self.create_random_name(prefix='cli', length=24)
self.cmd('az storage account create -n {} -g {}'.format(name, resource_group),
checks=[JMESPathCheck('isSftpEnabled', None)])

self.cmd('az storage account create -n {} -g {} --enable-sftp'.format(name1, resource_group),
checks=[JMESPathCheck('isSftpEnabled', True)])

self.cmd('az storage account create -n {} -g {} --enable-sftp false'.format(name2, resource_group),
checks=[JMESPathCheck('isSftpEnabled', False)])

self.cmd('az storage account create -n {} -g {} --enable-sftp true'.format(name3, resource_group),
checks=[JMESPathCheck('isSftpEnabled', True)])

self.cmd('az storage account update -n {} --enable-sftp false'.format(name3),
checks=[JMESPathCheck('isSftpEnabled', False)])

self.cmd('az storage account update -n {} --enable-sftp true'.format(name2),
checks=[JMESPathCheck('isSftpEnabled', True)])

self.cmd('az storage account update -n {} --enable-sftp'.format(name),
checks=[JMESPathCheck('isSftpEnabled', True)])

@api_version_constraint(ResourceType.MGMT_STORAGE, min_api='2019-06-01')
@ResourceGroupPreparer(location='eastus', name_prefix='cli_storage_account_routing')
def test_storage_account_with_routing_preference(self, resource_group):
Expand Down