Skip to content

Commit 8ee23c2

Browse files
calvinhzyazclibot
andauthored
[Storage] az storage account create/update: Support --enable-smb-oauth to allow managed identities to access SMB shares using OAuth (#32177)
Co-authored-by: Azure CLI Team <AzPyCLI@microsoft.com>
1 parent d34b7ce commit 8ee23c2

4 files changed

Lines changed: 1198 additions & 2 deletions

File tree

src/azure-cli/azure/cli/command_modules/storage/_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
432432
help='Allow you to specify the type of endpoint. Set this to AzureDNSZone to create a large number '
433433
'of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the '
434434
'endpoint URL will have an alphanumeric DNS Zone identifier.')
435+
c.argument('enable_smb_oauth', arg_type=get_three_state_flag(),
436+
arg_group='Azure Files Identity Based Authentication',
437+
help='Specifies if managed identities can access SMB shares using OAuth. '
438+
'The default interpretation is false for this property.')
435439

436440
with self.argument_context('storage account private-endpoint-connection',
437441
resource_type=ResourceType.MGMT_STORAGE) as c:
@@ -523,6 +527,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
523527
c.argument('upgrade_to_storagev2', arg_type=get_three_state_flag(),
524528
help='Upgrade Storage Account Kind to StorageV2.')
525529
c.argument('yes', options_list=['--yes', '-y'], help='Do not prompt for confirmation.', action='store_true')
530+
c.argument('enable_smb_oauth', arg_type=get_three_state_flag(),
531+
arg_group='Azure Files Identity Based Authentication',
532+
help='Specifies if managed identities can access SMB shares using OAuth. ')
526533

527534
for scope in ['storage account create', 'storage account update']:
528535
with self.argument_context(scope, arg_group='Customer managed key',

src/azure-cli/azure/cli/command_modules/storage/operations/account.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc
7777
allow_cross_tenant_replication=None, default_share_permission=None,
7878
enable_nfs_v3=None, subnet=None, vnet_name=None, action='Allow', enable_alw=None,
7979
immutability_period_since_creation_in_days=None, immutability_policy_state=None,
80-
allow_protected_append_writes=None, public_network_access=None, dns_endpoint_type=None):
80+
allow_protected_append_writes=None, public_network_access=None, dns_endpoint_type=None,
81+
enable_smb_oauth=None):
8182
StorageAccountCreateParameters, Kind, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet = \
8283
cmd.get_models('StorageAccountCreateParameters', 'Kind', 'Sku', 'CustomDomain', 'AccessTier', 'Identity',
8384
'Encryption', 'NetworkRuleSet')
@@ -198,6 +199,14 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc
198199
directory_service_options='None')
199200
params.azure_files_identity_based_authentication.default_share_permission = default_share_permission
200201

202+
if enable_smb_oauth is not None:
203+
if params.azure_files_identity_based_authentication is None:
204+
params.azure_files_identity_based_authentication = AzureFilesIdentityBasedAuthentication(
205+
directory_service_options='None')
206+
params.azure_files_identity_based_authentication.smb_o_auth_settings = {
207+
"is_smb_o_auth_enabled": enable_smb_oauth
208+
}
209+
201210
if enable_large_file_share:
202211
LargeFileSharesState = cmd.get_models('LargeFileSharesState')
203212
params.large_file_shares_state = LargeFileSharesState("Enabled")
@@ -398,7 +407,7 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
398407
allow_cross_tenant_replication=None, default_share_permission=None,
399408
immutability_period_since_creation_in_days=None, immutability_policy_state=None,
400409
allow_protected_append_writes=None, public_network_access=None, upgrade_to_storagev2=None,
401-
yes=None):
410+
yes=None, enable_smb_oauth=None):
402411
StorageAccountUpdateParameters, Sku, CustomDomain, AccessTier, Identity, Encryption, NetworkRuleSet, Kind = \
403412
cmd.get_models('StorageAccountUpdateParameters', 'Sku', 'CustomDomain', 'AccessTier', 'Identity', 'Encryption',
404413
'NetworkRuleSet', 'Kind')
@@ -610,6 +619,15 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non
610619
else instance.azure_files_identity_based_authentication
611620
params.azure_files_identity_based_authentication.default_share_permission = default_share_permission
612621

622+
if enable_smb_oauth is not None:
623+
if params.azure_files_identity_based_authentication is None:
624+
params.azure_files_identity_based_authentication = AzureFilesIdentityBasedAuthentication(
625+
directory_service_options='None') if instance.azure_files_identity_based_authentication is None \
626+
else instance.azure_files_identity_based_authentication
627+
params.azure_files_identity_based_authentication.smb_o_auth_settings = {
628+
"is_smb_o_auth_enabled": enable_smb_oauth
629+
}
630+
613631
if assign_identity:
614632
params.identity = Identity(type='SystemAssigned')
615633
if enable_large_file_share:

0 commit comments

Comments
 (0)