Why might you want SMB in the cloud? Essentially, the Microsoft Azure File Service lets you access SMB shares that live up in the Azure cloud service without having to configure Windows Server virtual machines first, set up their networking and then create file shares.
It is a service that lets you set up a file share right from the Azure management console, abstracting away all of the operating system and networking goofiness and letting Microsoft take care of making the file share fault tolerant and resistant to disaster. In addition, developers will appreciate that you get a REST API interface to access the files as well, so your on-premises analytics software and other resources can access files on the Azure Files share without necessarily having to be hosted in the cloud in the first place.
This capability to just spin up a file share within seconds that is accessible to all of the resources you already have set up on your Microsoft Azure account could come in handy in a variety of scenarios. Here are four scenarios:
First, you can use Azure Files to serve as a shared resource so that your development and test machines can access a single file share to install various applications, utilities and tools that are needed to fully deploy in your environment.
Azure Files could also be a centralized location for applications to place their configuration files so that when those applications are spread across virtual machines, they can read the settings files from a single, correct source. It would also be easier to make changes to settings in this one place and have them propagate out to all of the instances of the application.
You could deploy an Azure Files share to be a single place for your applications to store their logs, crash dumps, and other ancillary monitoring files.
Finally, if you are trying to move an application from on-premises into the cloud, and that application depends on SMB access (many on-premises applications seem to store data either in SQL or in a series of binary files accessed over SMB, the latter would potentially work well with this technology), then Azure Files could be a great way to create those shares without having to fire up an additional set of virtual machines just to host file-sharing workloads.
Getting started with the Microsoft Azure File Service
It is relatively simple to get started with the service. Log on to the Microsoft Azure management portal using the relevant Microsoft Account or organizational account. Then, sign up for access to the Azure File Service preview. Approvals come fairly quickly, and as soon as the service is out of the preview phase, you will not have to complete this step.
Once you have received email confirming your approval to use the preview service, create a new storage account. That's all there is to it; as part of the provisioning service, you get an "endpoint" assigned that takes the form of Accountname.file.core.windows.net.
This endpoint is how you will address the file shares using SMB. But first you need to create the shares that will reside at that endpoint. Here’s how it’s done through PowerShell:
- Download the Azure Files cmdlets.
- Right-click on the downloaded file and unblock it on the General tab.
- Extract the zip to wherever on your local system you would like it, and then open PowerShell and switch to that location.
- Run the following commands. Note that the account name and account key values are available from the Azure management console.
$storagecontext=New-AzureStorageContext <account name> <account key>
$azureshare=New-AzureStorageShare <put your share name here> -Content $storagecontext`
The share will be created, and you then can put in files and create folders using the $azureshare variable in PowerShell that we just established. For example, here is how to create a new directory:
New-AzureStorageDirectory -Share $azureshare -Path directoryname
You can upload a file to that new directory on the Azure Files share here:
Set-AzureStorageFileContent -Share $azureshare -Source C:\filetoupload.txt -Path directoryname
Once your share has been populated with content, you can access it using a regular NET USE command from any Azure resource that is hosted in the same availability region.
net use z: \\<accountname>.file.core.windows.net\<sharename> /u:<account name> <account key>
Drop everything and jump on the SMB 3 bandwagon