1

I am trying to map a blob storage to Z: with the drive label "Azure Blob Storage" but for some reason the location is not recognized.

I am getting this exception:

Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port
445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port.

azure

LSTest represents the FOLDER TO MAP parameter

The first thing I did is telnet to see if port is open:

telnet

 C:\Windows\system32>telnet https://analyticsdev.blob.core.windows.net/ 445
 Connecting To https://analyticsdev.blob.core.windows.net/...Could not open connection to the host, on port 445: Connect failed

I also did nslookup, but it didn't find the storage location apparently

How didn't it find it when clearly it exists given my screenshot?

also telnet with address+port:

 C:\Windows\system32>nslookup https://analyticsdev.blob.core.windows.net/
 Server:  XXXXX.attlocal.net
 Address:  2600:...::1
    
 *** XXXXX.attlocal.net can't find https://analyticsdev.blob.core.windows.net/: Non-existent domain

This is my script:

#set default values
if(!$BLOB_STORAGE_LOCATION) {
    $BLOB_STORAGE_LOCATION = "https://analyticsdev.blob.core.windows.net/"
}
if(!$STORAGE_ACCOUNT_NAME) {
    $STORAGE_ACCOUNT_NAME = "analyticsdev"
}
if(!$ACCESS_KEY) {
    $ACCESS_KEY = "2*********************="
}
if(!$FOLDER_TO_MAP) {
    $FOLDER_TO_MAP = "LSTest"
}
if(!$DRIVE_LETTER) {
    $DRIVE_LETTER = "Z"
}
if(!$DRIVE_LABEL) {
    $DRIVE_LABEL = "Azure Blob Storage"
}

<#
Author: Hadi Nasser
Purpose: This script will map a Blob Storage as network drive
#>

$connectTestResult = Test-NetConnection -ComputerName $BLOB_STORAGE_LOCATION -Port 445

if ($connectTestResult.TcpTestSucceeded) {
    # Save the password so the drive will persist on reboot
    cmd.exe /C "cmdkey /add:`"$BLOB_STORAGE_LOCATION`" /user:`"$STORAGE_ACCOUNT_NAME`" /pass:`"$ACCESS_KEY`""
    # Mount the drive
    New-PSDrive -Name $DRIVE_LETTER -PSProvider FileSystem -Root "\\$BLOB_STORAGE_LOCATION\$FOLDER_TO_MAP" -Persist
} 
else {
    Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}

(New-Object -ComObject Shell.Application).NameSpace("$($DRIVE_LETTER):").Self.Name = $DRIVE_LABEL
halfer
  • 19,824
  • 17
  • 99
  • 186
Cataster
  • 3,081
  • 5
  • 32
  • 79
  • You cannot connect to Azure Blob Storage that way. It is only possible for Azure File Storage. – Gaurav Mantri Aug 30 '21 at 16:26
  • @GauravMantri so you mean "File Shares" data storage instead of container is what I should be using? – Cataster Aug 30 '21 at 18:23
  • 1
    That's correct. You can mount File Shares and not Blob Containers. – Gaurav Mantri Aug 31 '21 at 00:12
  • @GauravMantri Even to a file share its failing: `C:\Windows\system32>telnet https://analyticsdev.file.core.windows.net/ls-test 445` Error: `Connecting To https://analyticsdev.file.core.windows.net/ls-test...Could not open connection to the host, on port 445: Connect failed` – Cataster Sep 02 '21 at 05:36
  • I am not sure if telnet is supported. Can you try to mount the file share using File Explorer? – Gaurav Mantri Sep 02 '21 at 06:18
  • @GauravMantri I tried the script generated automatically on Azure when I click ”Connect”. It suggested I connect to a p2s vpn which I did, but even that ps1 script failed – Cataster Sep 02 '21 at 06:25
  • 2
    When doing telnet or nslookup you need to specify host, not the URL. `nslookup analyticsdev.blob.core.windows.net Server: localhost Address: 127.0.0.1 Non-authoritative answer: Name: blob.db3prdstr13a.store.core.windows.net Address: 52.239.137.68 Aliases: analyticsdev.blob.core.windows.net ` – Hardoman Sep 23 '21 at 10:34
  • @Hardoman oh you're right, thanks! – Cataster Sep 23 '21 at 16:01

1 Answers1

1

As suggested by @Gaurav Mantri in the comment section you can not mount the blob container. You can mount the file share. please check this to Mount SMB Azure file share on Windows

based on the error you are getting it seems like port 445 is blocked in your network. please Work with your IT department or ISP to open port 445 outbound .

You can find some other options available in this thread

JayakrishnaGunnam-MT
  • 1,548
  • 1
  • 5
  • 9
  • I have checked out Azure File Sync, and unfortunately i dont have a windows server to install the Sync agent on :( however, my power was actually out due to a storm, so i connected to Mobile Hotspot, and I was able to connect over port 445! So its not an organizational issue, its rather my ISP (ATT) that has port 445 blocked... – Cataster Sep 23 '21 at 16:36
  • Update: Even with the file share mapped, i couldnt perform a backup operation as I had hoped I could. I actually ended up create a Windows VM on Azure using the free 1 month trial and installed the Azure File Sync Agent and created a storage account > Azure File Share and also created an Azure Sync Storage Service to hook up with the agent installed on the server. I registered the server with the Azure Storage Sync Service and proceeded to create a "Sync Group" alongside a server endpoint in it to map the local path on the server where files would sync – Cataster Sep 24 '21 at 01:19