Showing posts with label Storage Account. Show all posts
Showing posts with label Storage Account. Show all posts

Friday, November 22, 2019

How to copy files from Azure Fileshare to Azure Blob Containers

Hello Readers !

Below is a small useful blog content on how do we copy file copy files between Azure Blob containers and Azure fileshares using Azcopy.

For dummies, Azcopy is a command-line utility tool to work with Azure storage which you can download it from here. This is supposed to work faster than your azure storage explorer. You may do a comparison check yourself to confirm that. At present, Azure storage explorer, doesn't support copy-paste between two different services, lets say files and blobs.
One you download it , you can copy it into a windows folder and access it from your CMD.

For running AzCopy commands, in Command prompt you should navigate to the directory/folder which is holding your Azcopy.exe.

For example, I have kept it in C:\Azcopy . 
To run Azcopy commands, in command prompt I should get to the localion by running the below.

CD C:\Azcopy

Command to copy file from Azure fileshare to an Azure blob container.


Azcopy copy "<Azure FileshareURL>?<SAS key of storage account which hosts this azureFileshare>" "<AzureBlob Container/folder URL >?<SAS key of storage account hosting this blob container >"
 --recursive 

To get the URLs of your fileshare and blob containers, you can navigate to that in your Storage explorer or in Azure Portal and right click and get the "properties" which will have it.

Sample is given below.

Azcopy copy "https://mystorageac1.file.core.windows.net/backups/Prod?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-11-21T17:32:48Z&st=2019-11-21T09:32:48Z&spr=https,http&sig=5CPP5XJ4c%2jjbhbhbhbhbhcBjlZGeoNWFFtXNJMoI%3D" "https://mystorageac2.blob.core.windows.net/stagingbackups?sv=2019-02-02&ss=bfqt&srt=sco&sp=rwdlacup&se=2020-11-21T17:32:48Z&st=2019-11-21T09:32:48Z&spr=https,http&sig=5CPP5XihbhbhbObb90ocBjlZGeoNWFFtXNJMoI%3D" --recursive 

You will experience a magical speed over 6 GB/Sec while copying files between two azure locations as the data transfer happens with in the azure network itself and with Azcopy you are only triggering the transfer. 

Needless to say, the same tool can be used to move files between your local folders and Azure file shares/blob containers. Only difference is that you don't have to add a '?' sign, followed by the key to get access. Also make sure you give enough permissions when you are generating the SAS keys in your Azcopy commands. 

Hope that helps. Please write down your related questions  below in the comments section. I will get back to you at the earliest.



Saturday, October 26, 2019

Adding your Managed Instance Subnet in your storage Account's Network and Firewall settings

Hello Readers!

The below blog content is to highlight an azure limitation and a workaround to fix that till Azure came up with a direct solution for it. Its about enabling access for managed instance in the network and firewall settings of a storage account , if you are choosing the 'Public- Selected Networks ' configuration.

If you have noticed, when we add a particular VNet/Subnet to the settings, it will first enable service end points onto the subnet we are adding as the first step. This is not really possible for the dedicated subnet we create and maintain for Azure managed instances . As per design or existing configurations, managed instances' subnet can not have service end point enabled.

So how do we enable it?

There is a workaround for this limitation. 

We can find the managed endpoint IP address for the managed instances and whitelist that. It will be accepted in the network and firewall settings of the storage account , just like how we add a public IP to it. But the important part is having both your storage account and Managed instance in different Regions.

Below is how you do it.


Step1 : Finding the managed endpoint IP
Connect to Cloudshell (Powershell client embedded in the azure portal) or your own PowerShell client.

If you are logging in from your own Powershell client, make sure you have Az module installed by running the below commands and you are logged into your subscription.

Install-Module -Name Az #Installing Az module

connect-Azaccount #Logging into Azure subscription

resolve-dnsname 'xxxxx-mi1.xxxxx.database.windows.net' | select -first 1  | %{ resolve-dnsname $_.NameHost.Replace(".vnet","")}  #Finding the managed endpoint IP of your managed instance.

Please replace "xxxxx-mi1.xxxxx.database.windows.net" in the above script with the private endpoint URL of your managed instance which you get from the "Connection strings" of your managed instance in the Azure portal.

Managed endpoint address is common for all the instances in your MI subnet. 

Step2: Adding the IP into the firewall settings of the storage account.

This was covered in the bottom of my previous blog on storage account . Access it from here. 

May be in future, microsoft will come with a better solution which would support enabling service end point in MI Subnet. Let us all keep checking azure updates page 

Thats the end of this blog. Please follow if you are finding my blogs knowledgeable. If you do , you will receive notifications when I post something new here. Thanks for reading and Connecting ! 

Sunday, October 13, 2019

Using Azure Storage explorer to upload and download files to and from your Azure storage accounts

Hello Readers!

This is my third blog  on azure Storage accounts. You can find my previous blogs on storage accounts here . Part1 Part2. 

With the below , I am showing here how to use Azure Storage explorer to upload and download files to /from your Storage account. Please install azure explorer according to your platform (Windows/Linux etc)  from here
Before we begin, I will explain about two tiny concepts in Storage account authentication.

Access keys: 

These works like passwords for authentication, yet do not expire unless someone (Storage account owner/Admin) regenerate it . There will be two access keys maintained for a storage account. The refresh button next to each will regenerate a new one which need to be updated if you have supplied it for authentication in your applications/Client connections.

You also have a connection string here, which contains the key and protocols etc.Copy them using the copy button at the end of the textbox.


Shared Access Signatures:

These are access keys that expires after a set date . We can also limit the access through various other options as shown in the below window.Below is a sample one I am showing for Demo. If you have noticed the last portion, it uses the access keys (key1/Key2) for signing. 



Once you click on Generate above, you will have the below window.

It has a connection string common across all other services , SAS token that you can use seperately and different SAS URLs for all 4 storage services.



You can either use the connection string from SAS or the access keys above for connecting from an azure storage explorer. Steps are as below.

Launch Azure storage explorer in your machine. 

Right click on Storage accounts and select "Connect to Azure Storage".
Select "Use a connection string" to use connection strings( copied from the steps above) in the next window to connect to your storage account.





Once you click on next, you should be able to see options like below( in the left pane)



You can create new blob containers, file shares, queues and tables by right clicking and selecting "Create New " options and upload or download files as needed. Mostly we would need the blob containers for uploading and downloading giant backup files if you are into Database migrations.

I will soon write on Database migrations using Native backup restore method . I think we are good now for the topic alone.

Thanks for Visiting !