public function createContainer($containerName, $options = null)
 {
     if (is_null($options)) {
         $options = new CreateContainerOptions();
         $options->setPublicAccess('container');
     }
     $this->restProxy->createContainer($containerName, $options);
     $this->_createdContainers[] = $containerName;
 }
 /**
  * コンテナーを作成する
  * 
  * IMPORTANT:
  * コンテナーの名前は、常に小文字にする必要があります。
  * コンテナー名に大文字が含まれている場合や、コンテナーの名前付け規則の他の違反がある場合、400 エラー (無効な要求) が発生することがあります。
  * コンテナーの名前付け規則については、https://msdn.microsoft.com/library/azure/dd135715.aspxをご覧ください。
  * 
  * @param type $containerName
  * @param type $publicAccess
  * @param type $metadata
  * @throws Exception
  */
 public function createBlobContainer($containerName, $publicAccess = PublicAccessType::NONE, $metadata = null)
 {
     $createContainerOptions = new CreateContainerOptions();
     $createContainerOptions->setPublicAccess($publicAccess);
     if ($metadata) {
         $createContainerOptions->setMetadata($metadata);
     }
     try {
         $this->blobRestProxy->createContainer($containerName, $createContainerOptions);
     } catch (Exception $e) {
         throw new Exception($e->getMessage(), $e->getCode());
     }
 }
Exemplo n.º 3
0
 public function createContainer($container_name, $container_options = null)
 {
     if (empty($container_options)) {
         $container_options = new CreateContainerOptions();
         $container_options->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
     }
     try {
         $this->getConnection()->createContainer($container_name, $container_options);
     } catch (ServiceException $ex) {
         throw new BackendException($ex->getMessage(), $ex->getCode());
     }
     return true;
 }
 public function createContainer($container, $publicAccess = PublicAccessType::BLOBS_ONLY)
 {
     if (!preg_match('/^(?!-)(?!.*--)[a-z0-9-]{3,63}+(?<!-)$/', $container)) {
         throw new HttpException(400, 'Invalid Container Name');
     }
     $container_lists = $this->listContainers('');
     foreach ($container_lists as $container_list) {
         if ($container_list->getName() == $container) {
             return false;
         }
     }
     $createContainerOptions = new CreateContainerOptions();
     $createContainerOptions->setPublicAccess($publicAccess);
     try {
         $this->azureProxy->createContainer($container, $createContainerOptions);
         return true;
     } catch (ServiceException $e) {
         $code = $e->getCode();
         $error_message = $e->getMessage();
         throw new HttpException($code, $error_message);
     }
 }
 protected function initialize()
 {
     $this->connectionString = 'DefaultEndpointsProtocol=' . ENDPOINT_PROTOCOL . ';AccountName=' . AZURE_BLOB_ACCOUNT_NAME . ';AccountKey=' . AZURE_BLOB_ACCOUNT_KEY;
     $this->containerName = sha1(HTTP_URL);
     $this->blobRestProxy = ServicesBuilder::getInstance()->createBlobService($this->connectionString);
     $objListContainersResult = $this->blobRestProxy->listContainers();
     foreach ($objListContainersResult->getContainers() as $objContainer) {
         if ($objContainer->getName() == $this->containerName) {
             return;
         }
     }
     $createContainerOptions = new CreateContainerOptions();
     $createContainerOptions->setPublicAccess(PublicAccessType::BLOBS_ONLY);
     try {
         // Create container.
         $this->blobRestProxy->createContainer($this->containerName, $createContainerOptions);
     } catch (ServiceException $e) {
         $code = $e->getCode();
         $error_message = $e->getMessage();
         echo $code . ": " . $error_message . "<br />";
     }
 }
Exemplo n.º 6
0
 public function store($filename, $data, $options = array())
 {
     $retrying = isset($options['retry']);
     $options['container'] = Config::get('storage.container', 'default');
     try {
         $this->createBlockBlob($filename, $data, $options);
         return $this->getBlobService()->getUri() . '/' . $options['container'] . '/' . $filename;
     } catch (ServiceException $e) {
         //
         // Blob Container doesn't exists yet. Let's create it.
         //
         if ($e->getCode() == 404 && !$retrying) {
             $create_container_options = new CreateContainerOptions();
             $create_container_options->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
             $create_container_options->addMetaData('created', date('U'));
             $this->getBlobService()->createContainer($options['container'], $create_container_options);
             // Container has been created. Let's retry storing blob file.
             $options['retry'] = true;
             return $this->store($filename, $data, $options);
         } else {
             throw $e;
         }
     }
 }
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::getContainerMetadata
  * @covers WindowsAzure\Blob\BlobRestProxy::_getContainerPropertiesImpl
  */
 public function testGetContainerMetadata()
 {
     // Setup
     $name = 'getcontainermetadata' . $this->createSuffix();
     $options = new CreateContainerOptions();
     $expected = array('name1' => 'MyName1', 'mymetaname' => '12345', 'values' => 'Microsoft_');
     $options->setMetadata($expected);
     $this->createContainer($name, $options);
     $result = $this->restProxy->getContainerProperties($name);
     $expectedETag = $result->getETag();
     $expectedLastModified = $result->getLastModified();
     // Test
     $result = $this->restProxy->getContainerMetadata($name);
     // Assert
     $this->assertEquals($expectedETag, $result->getETag());
     $this->assertEquals($expectedLastModified, $result->getLastModified());
     $this->assertEquals($expected, $result->getMetadata());
 }
 /**
  * Creates a public container
  *
  * @param string        $containerName Name of the container to create
  *
  * @param BlobRestProxy $storageClient Reference of storage client to use
  *
  * @throws ServiceException
  */
 public static function createPublicContainer($containerName, $storageClient = null)
 {
     $containerOptions = new CreateContainerOptions();
     $containerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
     $blobRestProxy = $null;
     try {
         if ($storageClient) {
             $blobRestProxy = $storageClient;
         } else {
             $blobRestProxy = WindowsAzureStorageUtil::getStorageClient();
         }
         $blobRestProxy->createContainer($containerName, $containerOptions);
     } catch (ServiceException $e) {
         throw $e;
     }
 }
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::createContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::deleteContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::getContainerACL
  * @covers WindowsAzure\Blob\BlobRestProxy::getContainerMetadata
  * @covers WindowsAzure\Blob\BlobRestProxy::getContainerProperties
  * @covers WindowsAzure\Blob\BlobRestProxy::listContainers
  */
 public function testCreateContainerWithMetadataWorks()
 {
     // Act
     $opts = new CreateContainerOptions();
     $opts->setPublicAccess('blob');
     $opts->addMetadata('test', 'bar');
     $opts->addMetadata('blah', 'bleah');
     $this->restProxy->createContainer(self::$_creatable_container_2, $opts);
     $prop = $this->restProxy->getContainerMetadata(self::$_creatable_container_2);
     $prop2 = $this->restProxy->getContainerProperties(self::$_creatable_container_2);
     $acl = $this->restProxy->getContainerACL(self::$_creatable_container_2)->getContainerACL();
     $opts = new ListContainersOptions();
     $opts->setPrefix(self::$_creatable_container_2);
     $opts->setIncludeMetadata(true);
     $results2 = $this->restProxy->listContainers($opts);
     $this->restProxy->deleteContainer(self::$_creatable_container_2);
     // Assert
     $this->assertNotNull($prop, '$prop');
     $this->assertNotNull($prop->getETag(), '$prop->getETag()');
     $this->assertNotNull($prop->getLastModified(), '$prop->getLastModified()');
     $this->assertNotNull($prop->getMetadata(), '$prop->getMetadata()');
     $this->assertEquals(2, count($prop->getMetadata()), 'count($prop->getMetadata())');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('test', $prop->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'test\', $prop->getMetadata())');
     $this->assertTrue(!(array_search('bar', $prop->getMetadata()) === FALSE), '!(array_search(\'bar\', $prop->getMetadata()) === FALSE)');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('blah', $prop->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'blah\', $prop->getMetadata())');
     $this->assertTrue(!(array_search('bleah', $prop->getMetadata()) === FALSE), '!(array_search(\'bleah\', $prop->getMetadata()) === FALSE)');
     $this->assertNotNull($prop2, '$prop2');
     $this->assertNotNull($prop2->getETag(), '$prop2->getETag()');
     $this->assertNotNull($prop2->getLastModified(), '$prop2->getLastModified()');
     $this->assertNotNull($prop2->getMetadata(), '$prop2->getMetadata()');
     $this->assertEquals(2, count($prop2->getMetadata()), 'count($prop2->getMetadata())');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('test', $prop2->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'test\', $prop2->getMetadata())');
     $this->assertTrue(!(array_search('bar', $prop2->getMetadata()) === FALSE), '!(array_search(\'bar\', $prop2->getMetadata()) === FALSE)');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('blah', $prop2->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'blah\', $prop2->getMetadata())');
     $this->assertTrue(!(array_search('bleah', $prop2->getMetadata()) === FALSE), '!(array_search(\'bleah\', $prop2->getMetadata()) === FALSE)');
     $this->assertNotNull($results2, '$results2');
     $this->assertEquals(1, count($results2->getContainers()), 'count($results2->getContainers())');
     $container0 = $results2->getContainers();
     $container0 = $container0[0];
     // The capitalizaion gets changed.
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('test', $container0->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'test\', $container0->getMetadata())');
     $this->assertTrue(!(array_search('bar', $container0->getMetadata()) === FALSE), '!(array_search(\'bar\', $container0->getMetadata()) === FALSE)');
     $this->assertTrue(Utilities::arrayKeyExistsInsensitive('blah', $container0->getMetadata()), 'Utilities::arrayKeyExistsInsensitive(\'blah\', $container0->getMetadata())');
     $this->assertTrue(!(array_search('bleah', $container0->getMetadata()) === FALSE), '!(array_search(\'bleah\', $container0->getMetadata()) === FALSE)');
     $this->assertNotNull($acl, '$acl');
 }
Exemplo n.º 10
0
 /**
  * Создать произвольный контейнер
  * 
  * @param type $name
  * @throws \WindowsAzure\Common\ServiceException
  */
 public function createContainer($name)
 {
     $createContainerOptions = new CreateContainerOptions();
     $createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
     try {
         // Создание контейнера.
         $this->blobRestProxy->createContainer($name, $createContainerOptions);
     } catch (ServiceException $e) {
         //@todo: ничего не делаем если вдруг контейнер уже создан
         //http://msdn.microsoft.com/ru-ru/library/windowsazure/dd179439.aspx
         if ($e->getCode() != 409) {
             //Значит другая ошибка и посему бросаем эксепшен
             throw $e;
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Creates a new container in the given storage account.
  * 
  * @param string                        $container The container name.
  * @param Models\CreateContainerOptions $options   The optional parameters.
  * 
  * @return none
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179468.aspx
  */
 public function createContainer($container, $options = null)
 {
     Validate::isString($container, 'container');
     Validate::notNullOrEmpty($container, 'container');
     $method = Resources::HTTP_PUT;
     $headers = array();
     $postParams = array();
     $queryParams = array(Resources::QP_REST_TYPE => 'container');
     $path = $container;
     $statusCode = Resources::STATUS_CREATED;
     if (is_null($options)) {
         $options = new CreateContainerOptions();
     }
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $metadata = $options->getMetadata();
     $headers = $this->generateMetadataHeaders($metadata);
     $this->addOptionalHeader($headers, Resources::X_MS_BLOB_PUBLIC_ACCESS, $options->getPublicAccess());
     $this->send($method, $headers, $queryParams, $postParams, $path, $statusCode);
 }
 public static function getInterestingCreateContainerOptions()
 {
     $ret = array();
     $options = new CreateContainerOptions();
     array_push($ret, $options);
     $options = new CreateContainerOptions();
     $options->setTimeout(10);
     array_push($ret, $options);
     $options = new CreateContainerOptions();
     $options->setTimeout(-10);
     array_push($ret, $options);
     $options = new CreateContainerOptions();
     $options->setPublicAccess('container');
     array_push($ret, $options);
     $options = new CreateContainerOptions();
     $options->setPublicAccess('blob');
     array_push($ret, $options);
     $options = new CreateContainerOptions();
     $metadata = array('foo' => 'bar', 'boo' => 'baz');
     $options->setMetadata($metadata);
     array_push($ret, $options);
     return $ret;
 }
Exemplo n.º 13
0
 /**
  * Tries to create new container if it does not exist.
  *
  * @param string $container The container name.
  *
  * @return none
  */
 private static function _tryCreateContainer($container)
 {
     try {
         $options = new CreateContainerOptions();
         $options->setPublicAccess(PublicAccessType::BLOBS_ONLY);
         self::$_blobRestProxy->createContainer($container, $options);
     } catch (ServiceException $e) {
         if ($e->getCode() != 409) {
             print_r($e);
             exit;
         }
     }
 }
Exemplo n.º 14
0
 $listContainersOptions = new ListContainersOptions();
 $listContainersOptions->setPrefix($container);
 //$listContainersResult = $blobRestProxy->listContainers($listContainersOptions);
 //$containerExists = false;
 // $containers = $listContainersResult->getContainers();
 // for($i = 0; $i < $containers.length; $i++){
 // print_r($containers[$i]);
 // }
 //foreach ($listContainersResult->getContainers() as $container) {
 //    if ($container->getName() == $container) {
 //        $containerExists = true;// The container exists.
 //        // No need to keep checking.
 //        break;
 //    }
 //}
 $createContainerOptions = new CreateContainerOptions();
 //$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
 //$blobRestProxy->addSignedIdentifier("uniqueid",time()+ 500,"r");
 $createContainerOptions->addMetaData("remove_action", $remove_action);
 $createContainerOptions->addMetaData("remove_access_times", $remove_access_times);
 $createContainerOptions->addMetaData("remove_hours", $remove_hours);
 try {
     $blobRestProxy->createContainer($container, $createContainerOptions);
 } catch (Exception $e) {
     $code = $e->getCode();
     // http://msdn.microsoft.com/library/azure/dd179439.aspx
     $error_message = $e->getMessage();
     if ($code == 409) {
         //The container already exist
         //error( $code.": ".$error_message); //uncomment this line for testing and to see code value and message
     }
 /**
  * @covers WindowsAzure\Blob\BlobRestProxy::createContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::deleteContainer
  * @covers WindowsAzure\Blob\BlobRestProxy::getContainerMetadata
  * @covers WindowsAzure\Blob\BlobRestProxy::listContainers
  */
 private function createContainerWorker($options)
 {
     $container = BlobServiceFunctionalTestData::getInterestingContainerName();
     $created = false;
     try {
         if (is_null($options)) {
             $this->restProxy->createContainer($container);
         } else {
             $this->restProxy->createContainer($container, $options);
         }
         $created = true;
         if (is_null($options)) {
             $options = new CreateContainerOptions();
         }
         if (!is_null($options->getTimeout()) && $options->getTimeout() < 1) {
             $this->assertTrue(false, 'Expect negative timeouts in $options to throw');
         }
         // Now check that the $container was $created correctly.
         // Make sure that the list of all applicable containers is correctly updated.
         $opts = new ListContainersOptions();
         $opts->setPrefix(BlobServiceFunctionalTestData::$testUniqueId);
         $qs = $this->restProxy->listContainers($opts);
         $this->assertEquals(count($qs->getContainers()), count(BlobServiceFunctionalTestData::$TEST_CONTAINER_NAMES) + 1, 'After adding one, with Prefix=(\'' . BlobServiceFunctionalTestData::$testUniqueId . '\'), then Containers length');
         // Check the metadata on the container
         $ret = $this->restProxy->getContainerMetadata($container);
         $this->verifyCreateContainerWorker($ret, $options);
         $this->restProxy->deleteContainer($container);
     } catch (ServiceException $e) {
         if (is_null($options)) {
             $options = new CreateContainerOptions();
         }
         if (is_null($options->getTimeout()) || $options->getTimeout() >= 1) {
             throw $e;
         } else {
             $this->assertEquals(500, $e->getCode(), 'getCode');
         }
     }
     if ($created) {
         try {
             $this->restProxy->deleteContainer($container);
         } catch (ServiceException $e) {
             // Ignore.
         }
     }
 }
<?php

require_once 'vendor\\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=vstechupdate;AccountKey=<어카운트키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess 접근 정책 설정
// CONTAINER_AND_BLOBS:
// 전체 엑세스 권한
//
// BLOBS_ONLY:
// blob들에 대해서만 읽기 권한.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// 컨테이너 메타데이터 설정
$createContainerOptions->addMetaData("VSTechUp", "Visual Studio");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
    // 컨테이너 생성
    $blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
} catch (ServiceException $e) {
    // 에러 핸들링
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";
            a{
                color:white;
                text-decoration: underline;
            }
        </style>
    </head>
    
 <?php 
require_once 'vendor\\autoload.php';
use WindowsAzure\Common\ServiceBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
$connectionString = "DefaultEndpointsProtocol=https;AccountName=smalltalkelc;AccountKey=9Dp8HQ0qsk3ZWW1fADulCa7KEMO3Py5gOeTadrcbSwPYl+O4se+b4hfCUhDbe7KoPz+4ioJj5YSyomNcIPnyUw==";
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
$createContainerOptions->addMetaData("key1", "value1");
$createContainerOptions->addMetaDasta("key2", "value2");
echo $connectionString;
try {
    // Create Container.
    $blobRestProxy->createContainer("mycontainer", $createContainerOptions);
} catch (ServiceException $e) {
    //Handl exception based on error codes and messages.
    //Error codes and messages are here:
    // http://msdn.microsoft.com/library/azure/dd179437.aspx
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";
}
?>
<?php

require_once 'vendor\\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=<저장소이름>;AccountKey=<저장소키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess 접근 정책 설정
// CONTAINER_AND_BLOBS:
// 전체 엑세스 권한
//
// BLOBS_ONLY:
// blob들에 대해서만 읽기 권한.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// 컨테이너 메타데이터 설정
$createContainerOptions->addMetaData("KCB", "Korea Community Day");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
    // 컨테이너 생성
    $blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
} catch (ServiceException $e) {
    // 에러 핸들링
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";
Exemplo n.º 19
0
 /**
  * Update a container with some properties
  *
  * @param string $container
  * @param array  $properties
  *
  * @throws NotFoundException
  * @return void
  */
 public function updateContainerProperties($container, $properties = [])
 {
     $this->checkConnection();
     $options = new CreateContainerOptions();
     $options->setMetadata($properties);
     //		$options->setPublicAccess('blob');
     $this->blobConn->setContainerMetadata($container, $options);
 }
Exemplo n.º 20
0
 /**
  * create a container
  * @param type $dir name of container
  * @param type $access can be cb(CONTAINER_AND_BLOBS) or b (BLOBS_ONLY)
  * CONTAINER_AND_BLOBS:     
  * Specifies full public read access for container and blob data.
  * proxys can enumerate blobs within the container via anonymous 
  * request, but cannot enumerate containers within the storage account.
  *
  * BLOBS_ONLY:
  * Specifies public read access for blobs. Blob data within this 
  * container can be read via anonymous request, but container data is not 
  * available. proxys cannot enumerate blobs within the container via 
  * anonymous request.
  * If this value is not specified in the request, container data is 
  * private to the account owner.
  * @return boolean
  */
 protected function createContainer($dir, $access = 'cb', array $metadata = array())
 {
     $createContainerOptions = new CreateContainerOptions();
     switch ($access) {
         case 'cb':
             $createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
             break;
         case 'b':
             $createContainerOptions->setPublicAccess(PublicAccessType::BLOBS_ONLY);
             break;
         default:
             $createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
     }
     foreach ($metadata as $key => $value) {
         $createContainerOptions->addMetaData($key, $value);
     }
     try {
         // Create container.
         $this->blobRestProxy->createContainer($dir, $createContainerOptions);
         return true;
     } catch (ServiceException $e) {
         // Handle exception based on error codes and messages.
         // Error codes and messages are here:
         // http://msdn.microsoft.com/it-it/library/windowsazure/dd179439.aspx
         $code = $e->getCode();
         $error_message = $e->getMessage();
         echo $code . ": " . $error_message . "<br />";
         return false;
     }
 }
<?php

require_once 'vendor\\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=xecondemo01;AccountKey=<어카운트키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess 접근 정책 설정
// CONTAINER_AND_BLOBS:
// 전체 엑세스 권한
//
// BLOBS_ONLY:
// blob들에 대해서만 읽기 권한.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// 컨테이너 메타데이터 설정
$createContainerOptions->addMetaData("XECON", "XpressEngine");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
    // 컨테이너 생성
    $blobRestProxy->createContainer("xecondevcontainer", $createContainerOptions);
} catch (ServiceException $e) {
    // 에러 핸들링
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";
 /**
  * @covers WindowsAzure\Blob\Models\CreateContainerOptions::addMetadata
  */
 public function testAddMetadata()
 {
     // Setup
     $container = new CreateContainerOptions();
     $key = 'key1';
     $value = 'value1';
     $expected = array($key => $value);
     // Test
     $container->addMetadata($key, $value);
     // Assert
     $this->assertEquals($expected, $container->getMetadata());
 }
<?php

require_once 'vendor\\autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Blob\Models\CreateContainerOptions;
use WindowsAzure\Blob\Models\PublicAccessType;
use WindowsAzure\Common\ServiceException;
// https://azure.microsoft.com/en-us/documentation/articles/storage-php-how-to-use-blobs/
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=vstechupdate;AccountKey=<어카운트키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$createContainerOptions = new CreateContainerOptions();
//setPublicAccess 접근 정책 설정
// CONTAINER_AND_BLOBS:
// 전체 엑세스 권한
//
// BLOBS_ONLY:
// blob들에 대해서만 읽기 권한.
$createContainerOptions->setPublicAccess(PublicAccessType::CONTAINER_AND_BLOBS);
// 컨테이너 메타데이터 설정
$createContainerOptions->addMetaData("Webinar", "Webinar Good");
$createContainerOptions->addMetaData("Azure", "Cloud");
try {
    // 컨테이너 생성
    $blobRestProxy->createContainer("phpcontainer", $createContainerOptions);
} catch (ServiceException $e) {
    // 에러 핸들링
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";