0
votes

I want to update configure an Azure storage mount with Azure File Share(PATH MAPPINGS) for Azure WebApp on Containers via Azure DevOps pipeline. To achieve this, I am currently using an 'Azure PowerShell task' (code below). However, the PowerShell script is configuring the 'Advance' option, and exposes the Storage Account Access Key. Is there a way to configure the 'Basic' one.

PowerShell 'New-AzWebAppAzureStoragePath' creates an 'advance' configuration.

There is also a Devops task 'Azure webapp for containers' which allows me to set 'app settings' and 'configuration settings', but no option for 'path mappings'.

Is there any alternative in PowerShell or Azure devops task, to create a 'path mapping' to Azure file share with 'BASIC' configuration.

enter image description here

Script:

try{

    # Check if AzureStoragePath (PATH MAPPINGS) already exists for the web app
    $webapp = get-AzWebApp -ResourceGroupName $webAppResourceGroupName -Name $webAppName
    if($webapp.AzureStoragePath -ne $null){
        # 'Path Mapping' to Azure storage File does not exist. Proceed with creating one.

        # Get Storage Account Primary Key
        $storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $storageResourceGroupName -AccountName $storageAccountName).value[0]
        $storageAccountContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey


        # Returns 'True' or 'False' depending whether File share exists or not
        $storageShareObject = get-azstorageshare -Name $storageFileShareName -context $storageAccountContext -erroraction silentlycontinue
        $storageShareExists = (($storageShareObject) -ne $null)

        if($storageShareExists -ne 'True'){
            $storageShareObjectFQDN = $storageShareObject.name + ".files.core.windows.net"
            # Create a WebApp Storage Path object
            $webAppStoragePathObject = New-AzWebAppAzureStoragePath -Name 'someConfig' -AccountName $storageShareObjectFQDN -Type AzureFiles -ShareName $storageFileShareName -AccessKey $storageAccountKey -MountPath "/edgemicro/config" 

            # Configure the 'Path mappings' for the web app
            Set-AzWebApp -ResourceGroupName $webAppResourceGroupName -Name $webAppName -AzureStoragePath $webAppStoragePathObject
        }
    }

    


}catch{
    # '$_' contains all the details about exception
    $_
}
1
Hi Did you get a chance to check out below answer? Please let me if it helped you to fix this issueLevi Lu-MSFT

1 Answers

1
votes

I can reproduce the same issue with Azure powershell.

However, You can use azure cli instead of azure powershell as workaround. See below command. Check here for more information.

az webapp config storage-account add --resource-group $storageResourceGroupName  --name $webAppName --custom-id "someConfig" --storage-type "AzureFiles" --share-name $storageFileShareName --account-name $storageAccountName --access-key $storageAccountKey  --mount-path "/parent"

With above azure cli command, you can create a basic configuration. See below screenshot:

enter image description here