I have this command in a powerShell script
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName -SkuName Premium_LRS -location $location -Kind "FileStorage" -enableLargeFileShare -AllowBlobPublicAccess $false -AllowSharedKeyAccess $false -EnableAzureActiveDirectoryDomainServicesForFile $true
For whatever reason, this storage account causes an error message when I try to create a file share using
$storageContext = $storageAccount.context
New-AzStorageShare -name $storageShareName -context $storageContext
This is the error message:
New-AzStorageShare : Key based authentication is not permitted on this storage account. HTTP Status Code: 403 - HTTP
Error Message: Key based authentication is not permitted on this storage account.
ErrorCode: KeyBasedAuthenticationNotPermitted
ErrorMessage: Key based authentication is not permitted on this storage account.
RequestId:f9294db8-301a-00e1-3dea-4c825b000000
Time:2021-05-19T20:05:56.8453700Z
At C:\tf\advantage\dev\deploy\scripts\azure-functions.ps1:2179 char:5
+ New-AzStorageShare -name $storageShareName -context $storageConte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzStorageShare], StorageException
+ FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.NewAzureStorageShar
e
I'm 99% sure it has something to do with the -AllowSharedKeyAccess $false because of the error message, and since when I take it out it works fine. But why is it breaking, I want to automate creation of File Shares with that setting toggled.

][1]
