Lesson Learned #125: Azure Storage Firewall and BCP

This post has been republished via RSS; it originally appeared at: Azure Database Support Blog articles.

We received some questions from our customers that they want to enable the firewall of their Azure Storage Account that they are using to import data using BCP. 

 

In this article we are going to explain how it is possible to do it. 

 

First of all, we need information about the advantages/disadvantages when we enable Azure Storage Account firewall:

 

 

Jose_Manuel_Jurado_1-1584733839252.png

 

 

 

  • If we used BCP command from a Virtual Machine  we are going to have an Access Denied error message even if we check Allow trusted Microsoft services to access this storage account or adding the IP in the public firewall.

What is the solution:

 

  • Added this storage account in the VNET of the Virtual Machine and BCP will work.
  • If you run the BCP command from OnPremises, you need to the IP in the firewall exceptions and BCP will work. 

How to configure:

 

  • In order to have the best performance, my suggestion is to run BCP from the machine running in Azure.
  • Create an Azure Storage Account with File Share Option enabled. 
  • Enable Azure Storage Account Firewall, adding the VNET/SUBNET of this Azure Virtual Machine. 
  • Mount the file share either OnPremises or in your Azure Virtual Machine, running the following commands:  
    • net use drivename: \\myfileshare.file.core.windows.net\mybcpfiles /u:Azure\myfileshare PrimaryKeyValue.

Jose_Manuel_Jurado_0-1584734016314.png

  • And from this point we could run BCP command using this drivername having the Azure Storage firewall enabled. 

Jose_Manuel_Jurado_0-1584734320063.png

 

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.