To mount a azure smb fileshare from an Azure DevOps Pipeline (Ubuntu) the following can be used without a password. Requirement: The DevOps Service Principle has the permission to access the fileshare
variables:
- name: AZURE_SUBSCRIPTION
value: 'mySubscription'
- name: STORAGE_ACCOUNT_NAME
value: 'mystorageaccount'
- name: SMB_PATH
value: '//mystorageaccount.file.core.windows.net/myfileshare'
- name: MNT_PATH
value: '/media/myfileshare'
steps:
- task: AzureCLI@2
displayName: 'Mount Installer Files Azure File Share'
inputs:
azureSubscription: $(AZURE_SUBSCRIPTION)
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
sudo mkdir -p $(MNT_PATH)
STORAGE_ACCOUNT_KEY=$(az storage account keys list --account-name $STORAGE_ACCOUNT_NAME | jq '.[0].value' -r)
echo "Testing Network Connection to $(SMB_PATH)"
nc -v -w 2 $(STORAGE_ACCOUNT_NAME).file.core.windows.net 445
echo "Mounting $(SMB_PATH) to $(MNT_PATH)"
sudo mount -t cifs $(SMB_PATH) $MNT_PATH -o username=$STORAGE_ACCOUNT_NAME,password=$STORAGE_ACCOUNT_KEY,serverino,nosharesock,actimeo=30,mfsymlinks,dir_mode=0777,file_mode=0777
echo "Show Files in the mounted directory: $(MNT_PATH)"
ls -l $(MNT_PATH)