���߂Ẵu���u���L���[�E�X�g���[�W�J���i1/2�j - ��IT (original) (raw)

���W Windows Azure�X�g���[�W�J������i��ҁj ���߂Ẵu���u���L���[�E�X�g���[�W�J�� �쑺�����������@�E ��n 2010/01/05

�@�{�e�́A�u���߂Ă�Windows Azure�e�[�u���E�X�g���[�W�J���v�ɑ�����҂ł���B�O�҂ł́AWindows Azure�X�g���[�W�̊T�v�ƁA�]���̃����[�V���i���E�f�[�^�x�[�X�Ƃ̈Ⴂ�ɂ‚��ĉ�������B�܂��AWindows Azure�X�g���[�W�̃e�[�u����p������{�I�ȃR�[�f�B���O��������A���p����ۂ̃|�C���g���q�ׂ��B

�@����̌�҂ł́AWindows Azure�X�g���[�W�̃u���u��L���[��p�����������@���Љ��B

��4. Windows Azure�u���u�E�X�g���[�W�ł̊J��

���u���u�E�X�g���[�W�̊K�w�\��

�@�u���u�E�X�g���[�W�͑傫�ȃI�u�W�F�N�g�i1�‚̃u���u�͍ő�1TBytes�j���i�[���邽�߂̃X�g���[�W�ł���B

�@�u���u�E�X�g���[�W�́A�X�g���[�W�E�A�J�E���g�A�R���e�i�A�u���u�̊K�w�\����񋟂���i���u���u�̉��ɂ́A�u���b�N�ƌĂ΂��K�w�����݂��邪�A�{�e�ł͎�舵��Ȃ��j�B

�u���u�E�X�g���[�W�̊K�w�\��

���X�g���[�W�E�A�J�E���g

�@�u���u�ɃA�N�Z�X���邽�߂̖��O��Ԃ̂����ł���̃��x���ł���B

���R���e�i

�@�u���u�̏W�����Ǘ����邱�Ƃ��”\�ł���A�ő�8KBytes�̃��^�f�[�^��t���ł���B

�@�܂��A�uPublic�v�ƁuPrivate�v�Ƃ���2�‚̋��L�|���V�[�����݂���BPublic�͒N�ł��R���e�i�̒��g���Q�Ɖ”\�ł���APrivate�͑Ή�����A�J�E���g�̏��L�҂��A�F�؂��ꂽ�A�N�Z�X�ɂ���Ă̂݃R���e�i�̒��g���Q�Ɖ”\�ł���B�Ȃ��A�u���u�̍쐬�A�X�V�A�폜�ɂ‚��ẮA�ǂ���̋��L�|���V�[��ݒ肵���ꍇ�ł��F�؂��v�������B

���u���u

�@�ő�1TBytes�܂ł̃o�C�i���E�f�[�^���i�[�”\�ȁu�y�[�W�E�u���u�v�ƁA�ő�200GBytes�܂ł̃o�C�i���E�f�[�^���i�[�”\�ȁu�u���b�N�E�u���u�v�����݂���B�u���b�N�E�u���u�ƃy�[�W�E�u���u�Ƃ��ɍő�8KBytes�̃��^�f�[�^��t�����邱�Ƃ��ł���B

�@�u���b�N�E�u���u�͘A���I�ȓǂݎ����s���f�[�^����舵�����ƂɓK���Ă���A�y�[�W�E�u���u�̓����_���E�A�N�Z�X���s���f�[�^����舵�����ƂɓK���Ă���B

�@�R���e�i�̋��L�|���V�[���uPublic�v�ł���ꍇ�A

http://127.0.0.1:10000/devstoreaccount1/mygallery/image0001.jpg

�Ƃ�����URI�ɑ΂��āi�����̗��Development Storage��URI�j�A�C�ӂ̃��[�U�[���F�؂Ȃ��Ńt�@�C�����擾�ł���B���̂悤�Ƀt�@�C���𒼐ڗv���ł���_���A�u���u�E�X�g���[�W�̑傫�ȓ����ł���B

���u���u�E�X�g���[�W�𗘗p�����A�v���P�[�V�����̍쐬�菇

�@�ȉ��ł́A�u���u�E�X�g���[�W�𗘗p���āA�A�b�v���[�h�����摜���ꗗ�\������A�v���P�[�V�������쐬����B

���̉�ʂ̂悤�ɁA���[�J��PC��ɂ���摜�t�@�C�����w�肵�āA���̉摜�̃^�C�g�����p�����i�����{��s�j�Őݒ肵�A�m�A�b�v���[�h�n�{�^�����N���b�N����ƁA���̉摜���u���u�E�X�g���[�W�Ɋi�[�����B

�u���u�E�X�g���[�W�𗘗p�����A�v���P�[�V�����̓���C���[�W
����q����Metadata�ɂ͓��{�ꂻ�̂܂܂�ݒ肷�邱�Ƃ͂ł��Ȃ��BMetadata�̓]����HTTP�w�b�_���g�p���čs���邽�߁iADO.NET�`����API��������REST�`����API���Ăԁj�A�m�^�C�g���n�ɓ��{��͓��͂ł��Ȃ��B

�@�u���u�E�X�g���[�W�𗘗p�����A�v���P�[�V�����̍쐬�菇�͈ȉ��̗���ƂȂ�B

ASP.NET Web���[���̍쐬
Web���[�����̃t�H�[����ʂ��쐬
Web���[�����̏������W�b�N���쐬

��ASP.NET Web���[���̍쐬

�@�O��́u��Windows Azure�N���E�h�E�T�[�r�X�̃\�����[�V�����̍쐬�菇�v���Q�l�ɁA�V�����uCloud Service�v�̃v���W�F�N�g�ƃ\�����[�V�������i�ȉ��̗�ł́uBlobConfirmCloudService�v�Ƃ������O�Łj�쐬���AASP.NET Web���[�����i�ȉ��̗�ł́uWebRole1�v�Ƃ������O�Łj�lj�����B�����āu**��**Development Storage�ɃA�N�Z�X���邽�߂̊�{�ݒ��v���s���B

��Web���[�����̃t�H�[����ʂ��쐬

�@Web���[����Web�t�H�[����ʁiDefault.aspx�j���쐬����BFileUpload�R���g���[���A�摜�̃^�C�g������͂���e�L�X�g�{�b�N�X�E�R���g���[���A�A�b�v���[�h�����𔭐������邽�߂̃{�^���E�R���g���[����lj�����B�܂��A�摜�̈ꗗ�\�����s�����߂�Repeater�R���g���[����lj�����B

�@��̓I�ɂ́A���̂悤�ȃR�[�h�ɂȂ�iC#�j�B

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebRole1._Default" %> Windows Azure�u���u�E�X�g���[�W�̃T���v��
�A�b�v���[�h�摜
<asp:FileUpload ID="FileUpload1" runat="server" />
�^�C�g��
<asp:TextBox ID="TitleTextBox" runat="server" />
<asp:Button ID="SubmitButton" Text="�A�b�v���[�h" runat="server" OnClick="SubmitButton_Click" />

�摜�ꗗ�i�ŏ���5���擾�j

<asp:Repeater ID="Repeater1" runat="server">
�^�C�g�� �摜
<%# Eval("Attributes.Metadata[Title]") %> <img src="<%# Eval("Uri") %>" width="70" />
Web���[����Web�t�H�[����ʂ̃R�[�h��iDefault.aspx�j

�@�Ȃ�VB�̏ꍇ�́A�擪�s���A

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebRole1._Default" %>

�ƂȂ�B

��Web���[�����̏������W�b�N���쐬

�@Web�t�H�[����ʂ̃R�[�h�E�r�n�C���h�E�t�@�C���iDefault.aspx.cs�^Default.aspx.vb�j�ɁA�u���u�̃f�[�^�E���X�g���擾����Repeater�R���g���[���Ƀo�C���h���鏈���ƁA�u���u�Ƀf�[�^���i�[���鏈����lj�����B��̓I�ɂ́A�ȉ��̂悤�ȃR�[�h�ɂȂ�B

using System; using System.Linq; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.StorageClient; namespace WebRole1 { public partial class _Default : System.Web.UI.Page { protected CloudBlobClient blobStorage; protected CloudBlobContainer blobContainer; protected void Page_Load(object sender, EventArgs e) {// *.cscfg �ݒ�t�@�C������X�g���[�W�E�A�N�Z�X�̏����擾 var storageAccount = CloudStorageAccount.FromConfigurationSetting( "DataConnectionString");// �u���u�E�X�g���[�W�E�A�J�E���g�̍쐬 blobStorage = storageAccount.CreateCloudBlobClient();// �R���e�i�����݂��Ȃ��ꍇ�͍쐬 blobContainer = blobStorage.GetContainerReference("mygallery"); blobContainer.CreateIfNotExist();// Public�A�N�Z�X�ɐݒ肵�A�Q�Ƃ����� var permissions = blobContainer.GetPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; blobContainer.SetPermissions(permissions); RefreshImage(); } protected void SubmitButton_Click(object sender, EventArgs e) {// �A�b�v���[�h if (FileUpload1.HasFile) { string blobAddressUri = String.Format("image_{0:10}_{1}.jpg", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks, Guid.NewGuid().ToString()); var blob = blobContainer.GetBlobReference(blobAddressUri); blob.Metadata["Title"] = TitleTextBox.Text; blob.UploadFromStream(FileUpload1.FileContent); } RefreshImage(); } private void RefreshImage() {// BlobList���擾����ۂ̃I�v�V���� var blobRequestOptions = new BlobRequestOptions(); blobRequestOptions.BlobListingDetails = BlobListingDetails.Metadata;// 5���̃u���u���擾 var blobList = blobContainer.ListBlobs(blobRequestOptions) .Take(5).ToList();// �u���u�E�f�[�^���o�C���h���� Repeater1.DataSource = blobList; Repeater1.DataBind(); } } } Imports Microsoft.WindowsAzure Imports Microsoft.WindowsAzure.StorageClient Partial Public Class _Default Inherits System.Web.UI.Page Protected blobStorage As CloudBlobClient Protected blobContainer As CloudBlobContainer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load' *.cscfg �ݒ�t�@�C������X�g���[�W�E�A�N�Z�X�̏����擾 Dim storageAccount = _ CloudStorageAccount.FromConfigurationSetting( _ "DataConnectionString")' �u���u�E�X�g���[�W�E�A�J�E���g�̍쐬 blobStorage = storageAccount.CreateCloudBlobClient()' �R���e�i�����݂��Ȃ��ꍇ�͍쐬 blobContainer = _ blobStorage.GetContainerReference("mygallery") blobContainer.CreateIfNotExist()' Public�A�N�Z�X�ɐݒ肵�Q�Ƃ����� Dim permissions = blobContainer.GetPermissions() permissions.PublicAccess = _ BlobContainerPublicAccessType.Container blobContainer.SetPermissions(permissions) RefreshImage() End Sub Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SubmitButton.Click' �A�b�v���[�h If FileUpload1.HasFile Then Dim blobAddressUri = _ String.Format("image_Sub0:10End Sub_Sub1End Sub.jpg", _ DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks, _ Guid.NewGuid().ToString()) Dim blob = blobContainer.GetBlobReference(blobAddressUri) blob.Metadata("Title") = TitleTextBox.Text blob.UploadFromStream(FileUpload1.FileContent) End If RefreshImage() End Sub Private Sub RefreshImage()' BlobList���擾����ۂ̃I�v�V���� Dim blobRequestOptions As New BlobRequestOptions() blobRequestOptions.BlobListingDetails _ = BlobListingDetails.Metadata' 5���̃u���u���擾 Dim blobList = blobContainer.ListBlobs(blobRequestOptions) _ .Take(5).ToList()' �u���u�E�f�[�^���o�C���h���� Repeater1.DataSource = blobList Repeater1.DataBind() End Sub End Class
Web���[�����̏����̃R�[�h��i��FDefault.aspx.cs�A���FDefault.aspx.vb�j

�@Web���[�����̃u���u�E�A�N�Z�X�����̃��W�b�N�Ƃ��āA�ȉ��̃��\�b�h���`�����B

�@�ȏ�ŁA�u���u�E�X�g���[�W�𗘗p�����T���v���E�A�v���P�[�V�����̍쐬�͊����ł���B�mF5�n�L�[��������Visual Studio����A�v���P�[�V���������s���A����m�F���Ă������������B

���u���u�E�X�g���[�W�̂��̂ق��̋@�\

�@�{�e�ł͎�舵��Ȃ����A�u���u�E�X�g���[�W�ł͈ȉ��̂悤�ȋ@�\�����p�ł���i�����́uNovember 2009 SDK�v�Œlj����ꂽ�V�@�\�ł���j�B

�@�����āA�L���[�E�X�g���[�W�̗��p���@���������B

�@INDEX
�@ ���W�FWindows Azure�X�g���[�W�J������i�O�ҁj
�@ ���߂Ă�Windows Azure�e�[�u���E�X�g���[�W�J��
�@ 1�DWindows Azure�X�g���[�W�̊T�v
�@ 2�DWindows Azure�e�[�u���E�X�g���[�W�ł̊J��
�@
�@ ���W�FWindows Azure�X�g���[�W�J������i��ҁj
�@ ���߂Ẵu���u���L���[�E�X�g���[�W�J��
3�DWindows Azure�u���u�E�X�g���[�W�ł̊J��
�@ 4�DWindows Azure�L���[�E�X�g���[�W�ł̊J��

Insider.NET �t�H�[���� �V���L��

�L�����A�A�b�v