Azure File Service in IIS

Source: Internet
Author: User
Tags microsoft address

Microsoft Azure's Storage Suite provides new service file services that allow us to run programs in Azure to share storage, a storage account that is not shared on-line, but the upper limit for each share is 5G. Because the file service uses the SMB2.1 protocol, the storage is transparent to us and can be stored directly in the form of a drive letter path. For example. NET platform in System.IO.File.

The following is a brief introduction to the process of using file service. In addition, the File service is Linux-enabled, but this time it is deployed on Windows.

Prepare storage Account

Storage accounts in Azure

Establishing a file service share

Create a share in a storage account via the File service API

You can create a share directly using the sample provided by Microsoft, address Https://github.com/Azure-Samples

China Azure provides the service address is not the same as the default Microsoft address, so in the configuration file needs to be modified, you can find the difference here https://msdn.microsoft.com/zh-cn/library/azure/dn578439.aspx

Mount File Service Share

Go to the VM console and add network credentials

Cmdkey/add:<yourstorageaccountname>.file.core.chinacloudapi.cn/user:<yourstorageaccountname>/pass: <YourStorageAccountKeyWhichEndsIn==>

can see if network credentials are saved successfully

Cmdkey/list

the network credentials are saved for the VM automatically mount shares after reboot

Mount shares

net use * \\filedemo. File.core.chinacloudapi.cn\demo1

Demo1 was just through the API established shares

You can see it in the file browser after the mount is successful

At this point, the File service has been successfully mounted in the VM, and the other details include how to mount the storage share in the web and Webrole, Workrole to refer to this article

Http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/27/persisting-connections-to-microsoft-azure-files.aspx

Currently in the VM, we can write some programs to run, just like using a local disk as the file service, for example

There is a problem, however, if we want to access it in the IIS Web site of the VM, we will get an error. The reason I think it is clear to everyone is that the permissions are not the same as the account that the IIS runs on and the account that we mount the shares on.

After the smear has been explored, it is finally possible for IIS to access the file share. It is essentially the same as our original network file sharing, but in the cloud we can not see the specific machine, is very abstract, so we only the illusion of the main, practice-oriented.

Before accessing a local directory outside the physical directory of the Web site in IIS, we usually use a virtual directory, and similarly, if we have a network directory attached to this machine, it can also be accessed using a virtual directory, which is actually the same. 2 physical machines also use Windows systems, IIS in a machine, shared folders in the B machine, the B machine assigns a user and folder permissions to the user, to mount the B machine's folder share in a machine, to configure IIS for a machine, to add virtual directories and to log in with that account.

This is actually the same thing here, but some of the details are different.

We can think of our VMS as a machine, and file sharing is B machine.

Create an account for a VM

the account name created here must be the same as the Azure the same name as the storage account, and the password is the access key for the account.

Setting the IIS application pool identity

Locate the app used in the IIS application pool, set its identity in the right-click Properties Advanced Settings, enter the account name and password you just created

Create a virtual directory

To create a virtual directory, address the virtual directory using the address used by the Mount share

Click here to select a specific user's settings, enter the account name and password you just created.

If the file service is a physical machine, then the storage account is the account created on it, and the account credentials are entered on the side of the VM.

In. NET we can now use the HttpContext.Current.Server.MapPath method to get the real physical path and store the file without paying attention to its specific location.

Azure File Service in IIS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.