diff --git a/src/storage-preview/azext_storage_preview/_params.py b/src/storage-preview/azext_storage_preview/_params.py index 91bbe238f78..28c903d9273 100644 --- a/src/storage-preview/azext_storage_preview/_params.py +++ b/src/storage-preview/azext_storage_preview/_params.py @@ -77,6 +77,13 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem azure_storage_sid_type = CLIArgumentType(min_api='2019-04-01', arg_group="Azure Active Directory Properties", help="Specify the security identifier (SID) for Azure Storage. " "Required when --enable-files-adds is set to True") + sam_account_name_type = CLIArgumentType(min_api='2021-08-01', arg_group="Azure Active Directory Properties", + help="Specify the Active Directory SAMAccountName for Azure Storage.", + is_preview=True) + t_account_type = self.get_models('ActiveDirectoryPropertiesAccountType', resource_type=CUSTOM_MGMT_STORAGE) + account_type_type = CLIArgumentType(min_api='2021-08-01', arg_group="Azure Active Directory Properties", + arg_type=get_enum_type(t_account_type), is_preview=True, + help="Specify the Active Directory account type for Azure Storage.") t_routing_choice = self.get_models('RoutingChoice', resource_type=CUSTOM_MGMT_STORAGE) routing_choice_type = CLIArgumentType( arg_group='Routing Preference', arg_type=get_enum_type(t_routing_choice), @@ -202,6 +209,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem c.argument('domain_guid', domain_guid_type) c.argument('domain_sid', domain_sid_type) c.argument('azure_storage_sid', azure_storage_sid_type) + c.argument('sam_account_name', sam_account_name_type) + c.argument('account_type', account_type_type) c.argument('enable_hierarchical_namespace', arg_type=get_three_state_flag(), options_list=['--enable-hierarchical-namespace', '--hns', c.deprecate(target='--hierarchical-namespace', redirect='--hns', hide=True)], @@ -300,6 +309,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem c.argument('domain_guid', domain_guid_type) c.argument('domain_sid', domain_sid_type) c.argument('azure_storage_sid', azure_storage_sid_type) + c.argument('sam_account_name', sam_account_name_type) + c.argument('account_type', account_type_type) c.argument('routing_choice', routing_choice_type) c.argument('publish_microsoft_endpoints', publish_microsoft_endpoints_type) c.argument('publish_internet_endpoints', publish_internet_endpoints_type) diff --git a/src/storage-preview/azext_storage_preview/operations/account.py b/src/storage-preview/azext_storage_preview/operations/account.py index f84c571435f..c9d0be8727d 100644 --- a/src/storage-preview/azext_storage_preview/operations/account.py +++ b/src/storage-preview/azext_storage_preview/operations/account.py @@ -22,6 +22,7 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc enable_files_aadds=None, bypass=None, default_action=None, assign_identity=False, enable_large_file_share=None, enable_files_adds=None, domain_name=None, net_bios_domain_name=None, forest_name=None, domain_guid=None, domain_sid=None, + sam_account_name=None, account_type=None, azure_storage_sid=None, enable_hierarchical_namespace=None, encryption_key_type_for_table=None, encryption_key_type_for_queue=None, routing_choice=None, publish_microsoft_endpoints=None, publish_internet_endpoints=None, @@ -102,7 +103,9 @@ def create_storage_account(cmd, resource_group_name, account_name, sku=None, loc net_bios_domain_name=net_bios_domain_name, forest_name=forest_name, domain_guid=domain_guid, domain_sid=domain_sid, - azure_storage_sid=azure_storage_sid) + azure_storage_sid=azure_storage_sid, + sam_account_name=sam_account_name, + account_type=account_type) # TODO: Enabling AD will automatically disable AADDS. Maybe we should throw error message params.azure_files_identity_based_authentication = AzureFilesIdentityBasedAuthentication( @@ -276,8 +279,8 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non enable_files_aadds=None, assign_identity=False, bypass=None, default_action=None, enable_large_file_share=None, enable_files_adds=None, 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, + domain_sid=None, azure_storage_sid=None, sam_account_name=None, account_type=None, + routing_choice=None, publish_microsoft_endpoints=None, publish_internet_endpoints=None, allow_blob_public_access=None, min_tls_version=None, allow_shared_key_access=None, identity_type=None, user_identity_id=None, key_vault_user_identity_id=None, sas_expiration_period=None, key_expiration_period_in_days=None, @@ -387,7 +390,9 @@ def update_storage_account(cmd, instance, sku=None, tags=None, custom_domain=Non net_bios_domain_name=net_bios_domain_name, forest_name=forest_name, domain_guid=domain_guid, domain_sid=domain_sid, - azure_storage_sid=azure_storage_sid) + azure_storage_sid=azure_storage_sid, + sam_account_name=sam_account_name, + account_type=account_type) # TODO: Enabling AD will automatically disable AADDS. Maybe we should throw error message params.azure_files_identity_based_authentication = AzureFilesIdentityBasedAuthentication( diff --git a/src/storage-preview/azext_storage_preview/tests/latest/recordings/test_storage_account_with_files_adds_sam_account_name.yaml b/src/storage-preview/azext_storage_preview/tests/latest/recordings/test_storage_account_with_files_adds_sam_account_name.yaml new file mode 100644 index 00000000000..492ddefadb7 --- /dev/null +++ b/src/storage-preview/azext_storage_preview/tests/latest/recordings/test_storage_account_with_files_adds_sam_account_name.yaml @@ -0,0 +1,308 @@ +interactions: +- request: + body: '{"sku": {"name": "Standard_RAGRS"}, "kind": "StorageV2", "location": "eastus2euap", + "properties": {"encryption": {"services": {"blob": {}}, "keySource": "Microsoft.Storage"}, + "azureFilesIdentityBasedAuthentication": {"directoryServiceOptions": "AD", "activeDirectoryProperties": + {"domainName": "mydomain.com", "netBiosDomainName": "mydomain.com", "forestName": + "mydomain.com", "domainGuid": "12345678-1234-1234-1234-123456789012", "domainSid": + "S-1-5-21-1234567890-1234567890-1234567890", "azureStorageSid": "S-1-5-21-1234567890-1234567890-1234567890-1234", + "samAccountName": "samaccount000003", "accountType": "User"}}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account create + Connection: + - keep-alive + Content-Length: + - '621' + Content-Type: + - application/json + ParameterSetName: + - -n -g -l --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002?api-version=2021-08-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + content-type: + - text/plain; charset=utf-8 + date: + - Thu, 13 Jan 2022 04:10:18 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus2euap/asyncoperations/ef440aed-afb7-4692-9252-6d0de5183d1d?monitor=true&api-version=2021-08-01 + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account create + Connection: + - keep-alive + ParameterSetName: + - -n -g -l --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus2euap/asyncoperations/ef440aed-afb7-4692-9252-6d0de5183d1d?monitor=true&api-version=2021-08-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + content-type: + - text/plain; charset=utf-8 + date: + - Thu, 13 Jan 2022 04:10:35 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus2euap/asyncoperations/ef440aed-afb7-4692-9252-6d0de5183d1d?monitor=true&api-version=2021-08-01 + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account create + Connection: + - keep-alive + ParameterSetName: + - -n -g -l --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus2euap/asyncoperations/ef440aed-afb7-4692-9252-6d0de5183d1d?monitor=true&api-version=2021-08-01 + response: + body: + string: '{"sku":{"name":"Standard_RAGRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002","name":"cli000002","type":"Microsoft.Storage/storageAccounts","location":"eastus2euap","tags":{},"properties":{"keyCreationTime":{"key1":"2022-01-13T04:10:16.6848412Z","key2":"2022-01-13T04:10:16.6848412Z"},"privateEndpointConnections":[],"azureFilesIdentityBasedAuthentication":{"directoryServiceOptions":"AD","activeDirectoryProperties":{"samAccountName":"samaccount000003","accountType":"User","domainName":"mydomain.com","netBiosDomainName":"mydomain.com","forestName":"mydomain.com","domainGuid":"12345678-1234-1234-1234-123456789012","domainSid":"S-1-5-21-1234567890-1234567890-1234567890","azureStorageSid":"S-1-5-21-1234567890-1234567890-1234567890-1234"}},"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2022-01-13T04:10:16.5910661Z","primaryEndpoints":{"dfs":"https://cli000002.dfs.core.windows.net/","web":"https://cli000002.z3.web.core.windows.net/","blob":"https://cli000002.blob.core.windows.net/","queue":"https://cli000002.queue.core.windows.net/","table":"https://cli000002.table.core.windows.net/","file":"https://cli000002.file.core.windows.net/"},"primaryLocation":"eastus2euap","statusOfPrimary":"available","secondaryLocation":"centraluseuap","statusOfSecondary":"available","secondaryEndpoints":{"dfs":"https://cli000002-secondary.dfs.core.windows.net/","web":"https://cli000002-secondary.z3.web.core.windows.net/","blob":"https://cli000002-secondary.blob.core.windows.net/","queue":"https://cli000002-secondary.queue.core.windows.net/","table":"https://cli000002-secondary.table.core.windows.net/"}}}' + headers: + cache-control: + - no-cache + content-length: + - '2197' + content-type: + - application/json + date: + - Thu, 13 Jan 2022 04:10:38 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account update + Connection: + - keep-alive + ParameterSetName: + - -n -g --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002?api-version=2021-08-01 + response: + body: + string: '{"sku":{"name":"Standard_RAGRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002","name":"cli000002","type":"Microsoft.Storage/storageAccounts","location":"eastus2euap","tags":{},"properties":{"keyCreationTime":{"key1":"2022-01-13T04:10:16.6848412Z","key2":"2022-01-13T04:10:16.6848412Z"},"privateEndpointConnections":[],"azureFilesIdentityBasedAuthentication":{"directoryServiceOptions":"AD","activeDirectoryProperties":{"samAccountName":"samaccount000003","accountType":"User","domainName":"mydomain.com","netBiosDomainName":"mydomain.com","forestName":"mydomain.com","domainGuid":"12345678-1234-1234-1234-123456789012","domainSid":"S-1-5-21-1234567890-1234567890-1234567890","azureStorageSid":"S-1-5-21-1234567890-1234567890-1234567890-1234"}},"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2022-01-13T04:10:16.5910661Z","primaryEndpoints":{"dfs":"https://cli000002.dfs.core.windows.net/","web":"https://cli000002.z3.web.core.windows.net/","blob":"https://cli000002.blob.core.windows.net/","queue":"https://cli000002.queue.core.windows.net/","table":"https://cli000002.table.core.windows.net/","file":"https://cli000002.file.core.windows.net/"},"primaryLocation":"eastus2euap","statusOfPrimary":"available","secondaryLocation":"centraluseuap","statusOfSecondary":"available","secondaryEndpoints":{"dfs":"https://cli000002-secondary.dfs.core.windows.net/","web":"https://cli000002-secondary.z3.web.core.windows.net/","blob":"https://cli000002-secondary.blob.core.windows.net/","queue":"https://cli000002-secondary.queue.core.windows.net/","table":"https://cli000002-secondary.table.core.windows.net/"}}}' + headers: + cache-control: + - no-cache + content-length: + - '2197' + content-type: + - application/json + date: + - Thu, 13 Jan 2022 04:10:41 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account update + Connection: + - keep-alive + ParameterSetName: + - -n -g --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002?api-version=2021-08-01 + response: + body: + string: '{"sku":{"name":"Standard_RAGRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002","name":"cli000002","type":"Microsoft.Storage/storageAccounts","location":"eastus2euap","tags":{},"properties":{"keyCreationTime":{"key1":"2022-01-13T04:10:16.6848412Z","key2":"2022-01-13T04:10:16.6848412Z"},"privateEndpointConnections":[],"azureFilesIdentityBasedAuthentication":{"directoryServiceOptions":"AD","activeDirectoryProperties":{"samAccountName":"samaccount000003","accountType":"User","domainName":"mydomain.com","netBiosDomainName":"mydomain.com","forestName":"mydomain.com","domainGuid":"12345678-1234-1234-1234-123456789012","domainSid":"S-1-5-21-1234567890-1234567890-1234567890","azureStorageSid":"S-1-5-21-1234567890-1234567890-1234567890-1234"}},"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2022-01-13T04:10:16.5910661Z","primaryEndpoints":{"dfs":"https://cli000002.dfs.core.windows.net/","web":"https://cli000002.z3.web.core.windows.net/","blob":"https://cli000002.blob.core.windows.net/","queue":"https://cli000002.queue.core.windows.net/","table":"https://cli000002.table.core.windows.net/","file":"https://cli000002.file.core.windows.net/"},"primaryLocation":"eastus2euap","statusOfPrimary":"available","secondaryLocation":"centraluseuap","statusOfSecondary":"available","secondaryEndpoints":{"dfs":"https://cli000002-secondary.dfs.core.windows.net/","web":"https://cli000002-secondary.z3.web.core.windows.net/","blob":"https://cli000002-secondary.blob.core.windows.net/","queue":"https://cli000002-secondary.queue.core.windows.net/","table":"https://cli000002-secondary.table.core.windows.net/"}}}' + headers: + cache-control: + - no-cache + content-length: + - '2197' + content-type: + - application/json + date: + - Thu, 13 Jan 2022 04:10:41 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"sku": {"name": "Standard_RAGRS"}, "tags": {}, "properties": {"encryption": + {"services": {"blob": {"enabled": true, "keyType": "Account"}, "file": {"enabled": + true, "keyType": "Account"}}, "keySource": "Microsoft.Storage"}, "accessTier": + "Hot", "azureFilesIdentityBasedAuthentication": {"directoryServiceOptions": + "AD", "activeDirectoryProperties": {"domainName": "mydomain.com", "netBiosDomainName": + "mydomain.com", "forestName": "mydomain.com", "domainGuid": "12345678-1234-1234-1234-123456789012", + "domainSid": "S-1-5-21-1234567890-1234567890-1234567890", "azureStorageSid": + "S-1-5-21-1234567890-1234567890-1234567890-1234", "samAccountName": "newsamaccount000004", + "accountType": "Computer"}}, "supportsHttpsTrafficOnly": true, "networkAcls": + {"bypass": "AzureServices", "virtualNetworkRules": [], "ipRules": [], "defaultAction": + "Allow"}}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - storage account update + Connection: + - keep-alive + Content-Length: + - '845' + Content-Type: + - application/json + ParameterSetName: + - -n -g --enable-files-adds --domain-name --net-bios-domain-name --forest-name + --domain-guid --domain-sid --azure-storage-sid --sam-account-name --account-type + User-Agent: + - AZURECLI/2.32.0 azsdk-python-azure-mgmt-storage/19.0.0 Python/3.7.9 (Windows-10-10.0.22000-SP0) + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002?api-version=2021-08-01 + response: + body: + string: '{"sku":{"name":"Standard_RAGRS","tier":"Standard"},"kind":"StorageV2","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/cli000002","name":"cli000002","type":"Microsoft.Storage/storageAccounts","location":"eastus2euap","tags":{},"properties":{"keyCreationTime":{"key1":"2022-01-13T04:10:16.6848412Z","key2":"2022-01-13T04:10:16.6848412Z"},"privateEndpointConnections":[],"azureFilesIdentityBasedAuthentication":{"directoryServiceOptions":"AD","activeDirectoryProperties":{"samAccountName":"newsamaccount000004","accountType":"Computer","domainName":"mydomain.com","netBiosDomainName":"mydomain.com","forestName":"mydomain.com","domainGuid":"12345678-1234-1234-1234-123456789012","domainSid":"S-1-5-21-1234567890-1234567890-1234567890","azureStorageSid":"S-1-5-21-1234567890-1234567890-1234567890-1234"}},"minimumTlsVersion":"TLS1_0","allowBlobPublicAccess":true,"networkAcls":{"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2022-01-13T04:10:16.6848412Z"}},"keySource":"Microsoft.Storage"},"accessTier":"Hot","provisioningState":"Succeeded","creationTime":"2022-01-13T04:10:16.5910661Z","primaryEndpoints":{"dfs":"https://cli000002.dfs.core.windows.net/","web":"https://cli000002.z3.web.core.windows.net/","blob":"https://cli000002.blob.core.windows.net/","queue":"https://cli000002.queue.core.windows.net/","table":"https://cli000002.table.core.windows.net/","file":"https://cli000002.file.core.windows.net/"},"primaryLocation":"eastus2euap","statusOfPrimary":"available","secondaryLocation":"centraluseuap","statusOfSecondary":"available","secondaryEndpoints":{"dfs":"https://cli000002-secondary.dfs.core.windows.net/","web":"https://cli000002-secondary.z3.web.core.windows.net/","blob":"https://cli000002-secondary.blob.core.windows.net/","queue":"https://cli000002-secondary.queue.core.windows.net/","table":"https://cli000002-secondary.table.core.windows.net/"}}}' + headers: + cache-control: + - no-cache + content-length: + - '2204' + content-type: + - application/json + date: + - Thu, 13 Jan 2022 04:10:49 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +version: 1 diff --git a/src/storage-preview/azext_storage_preview/tests/latest/test_storage_account_scenarios.py b/src/storage-preview/azext_storage_preview/tests/latest/test_storage_account_scenarios.py index 69f991ee47b..c34875a4f9b 100644 --- a/src/storage-preview/azext_storage_preview/tests/latest/test_storage_account_scenarios.py +++ b/src/storage-preview/azext_storage_preview/tests/latest/test_storage_account_scenarios.py @@ -28,6 +28,60 @@ def test_storage_account_sftp(self, resource_group): self.cmd('storage account update -n {sa} --enable-local-user false', checks=[JMESPathCheck('isSftpEnabled', False), JMESPathCheck('isLocalUserEnabled', False)]) + @api_version_constraint(CUSTOM_MGMT_STORAGE, min_api='2021-08-01') + @ResourceGroupPreparer() + def test_storage_account_with_files_adds_sam_account_name(self, resource_group): + name = self.create_random_name(prefix='cli', length=24) + self.kwargs.update({ + 'rg': resource_group, + 'sc': name, + 'domain_name': 'mydomain.com', + 'net_bios_domain_name': 'mydomain.com', + 'forest_name': 'mydomain.com', + 'domain_guid': '12345678-1234-1234-1234-123456789012', + 'domain_sid': 'S-1-5-21-1234567890-1234567890-1234567890', + 'azure_storage_sid': 'S-1-5-21-1234567890-1234567890-1234567890-1234', + 'sam_account_name': self.create_random_name(prefix='samaccount', length=48) + }) + create_cmd = """storage account create -n {sc} -g {rg} -l eastus2euap --enable-files-adds --domain-name + {domain_name} --net-bios-domain-name {net_bios_domain_name} --forest-name {forest_name} --domain-guid + {domain_guid} --domain-sid {domain_sid} --azure-storage-sid {azure_storage_sid} + --sam-account-name {sam_account_name} --account-type User""" + result = self.cmd(create_cmd).get_output_in_json() + + self.assertIn('azureFilesIdentityBasedAuthentication', result) + self.assertEqual(result['azureFilesIdentityBasedAuthentication']['directoryServiceOptions'], 'AD') + activeDirectoryProperties = result['azureFilesIdentityBasedAuthentication']['activeDirectoryProperties'] + self.assertEqual(activeDirectoryProperties['samAccountName'], self.kwargs['sam_account_name']) + self.assertEqual(activeDirectoryProperties['accountType'], "User") + self.assertEqual(activeDirectoryProperties['azureStorageSid'], self.kwargs['azure_storage_sid']) + self.assertEqual(activeDirectoryProperties['domainGuid'], self.kwargs['domain_guid']) + self.assertEqual(activeDirectoryProperties['domainName'], self.kwargs['domain_name']) + self.assertEqual(activeDirectoryProperties['domainSid'], self.kwargs['domain_sid']) + self.assertEqual(activeDirectoryProperties['forestName'], self.kwargs['forest_name']) + self.assertEqual(activeDirectoryProperties['netBiosDomainName'], self.kwargs['net_bios_domain_name']) + + self.kwargs.update({ + 'sam_account_name': self.create_random_name(prefix='newsamaccount', length=48) + }) + update_cmd = """storage account update -n {sc} -g {rg} --enable-files-adds --domain-name {domain_name} + --net-bios-domain-name {net_bios_domain_name} --forest-name {forest_name} --domain-guid {domain_guid} + --domain-sid {domain_sid} --azure-storage-sid {azure_storage_sid} + --sam-account-name {sam_account_name} --account-type Computer""" + result = self.cmd(update_cmd).get_output_in_json() + + self.assertIn('azureFilesIdentityBasedAuthentication', result) + self.assertEqual(result['azureFilesIdentityBasedAuthentication']['directoryServiceOptions'], 'AD') + activeDirectoryProperties = result['azureFilesIdentityBasedAuthentication']['activeDirectoryProperties'] + self.assertEqual(activeDirectoryProperties['samAccountName'], self.kwargs['sam_account_name']) + self.assertEqual(activeDirectoryProperties['accountType'], "Computer") + self.assertEqual(activeDirectoryProperties['azureStorageSid'], self.kwargs['azure_storage_sid']) + self.assertEqual(activeDirectoryProperties['domainGuid'], self.kwargs['domain_guid']) + self.assertEqual(activeDirectoryProperties['domainName'], self.kwargs['domain_name']) + self.assertEqual(activeDirectoryProperties['domainSid'], self.kwargs['domain_sid']) + self.assertEqual(activeDirectoryProperties['forestName'], self.kwargs['forest_name']) + self.assertEqual(activeDirectoryProperties['netBiosDomainName'], self.kwargs['net_bios_domain_name']) + @api_version_constraint(CUSTOM_MGMT_STORAGE, min_api='2016-12-01') class StorageAccountNetworkRuleTests(StorageScenarioMixin, ScenarioTest):