/**
  * Connects to a Azure Blob Storage
  *
  * @param array $config Authentication configuration
  *
  * @throws InvalidArgumentException
  * @throws InternalServerErrorException
  * @throws \Exception
  */
 public function __construct($config)
 {
     $credentials = $config;
     $this->container = ArrayUtils::get($config, 'container');
     Session::replaceLookups($credentials, true);
     $connectionString = ArrayUtils::get($credentials, 'connection_string');
     if (empty($connectionString)) {
         $name = ArrayUtils::get($credentials, 'account_name', ArrayUtils::get($credentials, 'AccountName'));
         if (empty($name)) {
             throw new InvalidArgumentException('WindowsAzure account name can not be empty.');
         }
         $key = ArrayUtils::get($credentials, 'account_key', ArrayUtils::get($credentials, 'AccountKey'));
         if (empty($key)) {
             throw new InvalidArgumentException('WindowsAzure account key can not be empty.');
         }
         $protocol = ArrayUtils::get($credentials, 'protocol', 'https');
         $connectionString = "DefaultEndpointsProtocol={$protocol};AccountName={$name};AccountKey={$key}";
     }
     try {
         $this->blobConn = ServicesBuilder::getInstance()->createBlobService($connectionString);
         if (!$this->containerExists($this->container)) {
             $this->createContainer(['name' => $this->container]);
         }
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("Windows Azure Blob Service Exception:\n{$ex->getMessage()}");
     }
 }
Beispiel #2
0
 /**
  * Конструктор обьекта
  * 
  * @param type $options
  * @throws Exception
  */
 public function __construct($options)
 {
     $connectionOption = array();
     if (isset($options['СreateContainerName'])) {
         $this->createContainerName = $options['СreateContainerName'] === true;
     }
     if (!isset($options['FilePrefix'])) {
         throw new Exception('Required option "FilePrefix" is missing.');
     }
     $this->filePrefix = rtrim($options['FilePrefix'], '/');
     if (!isset($options['UseDevelopmentStorage'])) {
         $connectionOption['DefaultEndpointsProtocol'] = isset($options['DefaultEndpointsProtocol']) ? $options['DefaultEndpointsProtocol'] : 'https';
         if (!isset($options['AccountName'])) {
             throw new Exception('Required option "AccountName" is missing.');
         }
         $connectionOption['AccountName'] = $options['AccountName'];
         if (!isset($options['AccountKey'])) {
             throw new Exception('Required option "AccountKey" is missing.');
         }
         $connectionOption['AccountKey'] = $options['AccountKey'];
     } else {
         $connectionOption['UseDevelopmentStorage'] = 'true';
     }
     $this->connectionString = urldecode(http_build_query($connectionOption, '', ';'));
     $this->blobRestProxy = ServicesBuilder::getInstance()->createBlobService($this->connectionString);
 }
 public function __construct(callable $conf)
 {
     $endpoint = sprintf($conf('FS_AZURE_PROTOCOL'), $conf('FS_AZURE_USERNAME'), conf('FS_AZURE_API_KEY'));
     $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
     $adapter = new AzureAdapter($blobRestProxy, conf('FS_AZURE_CONTAINER'));
     $this->constructFileSystem($adapter);
 }
 function getCloudService($jsonParams)
 {
     $arg1 = 'providername';
     $accountprovider = $jsonParams->{$arg1};
     $arg1 = 'domain';
     $domain = $jsonParams->{$arg1};
     $arg10 = 'cloudproviders';
     $cloudproviders = $jsonParams->{$arg10};
     $providerArray = json_decode($cloudproviders);
     $subscriptionid = "subscriptionid";
     $subscrid = $providerArray->{$accountprovider}->{$subscriptionid};
     loghandler(DEBUG, "Subscription id:" . $subscrid);
     $certpath = "ServiceManagementAPICertificate";
     $certfpath = $providerArray->{$accountprovider}->{$certpath};
     loghandler(DEBUG, "Certificate path:" . $certfpath);
     //$connectionString="SubscriptionID=".$subscrid.";CertificatePath=/var/cloudbox/azurecer/mycert.pem";
     $connectionString = "SubscriptionID=" . $subscrid . ";CertificatePath=/var/cloudbox/" . $domain . "/data/keys/" . $certfpath;
     loghandler(DEBUG, "Connection String:" . $connectionString);
     try {
         $serviceManagementRestProxy = ServicesBuilder::getInstance()->createServiceManagementService($connectionString);
         return $serviceManagementRestProxy;
     } catch (Exception $se) {
         $message = $se->getMessage();
         trigger_error($message, E_USER_ERROR);
     }
     return null;
 }
Beispiel #5
0
 protected function init()
 {
     if (empty($this->blobProxy)) {
         $config = Config::getInstance()->get('Octo.Azure.BlobStorage');
         $this->blobProxy = ServicesBuilder::getInstance()->createBlobService($config['ConnectionString']);
     }
 }
 public function connect()
 {
     if (empty($this->connection_string)) {
         throw new BackendException("Connection string not specified.");
     }
     $this->connection = ServicesBuilder::getInstance()->createServiceBusService($this->connection_string);
 }
Beispiel #7
0
 /**
  * @param string $name
  * @param array $config
  * @return League\Flysystem\Adapter\AbstractAdapter
  */
 protected function prepareAdapter($name, $config)
 {
     if (!isset($this->adaptersMap[$name])) {
         throw new \Exception(sprintf('Unknown adapter "%s".', $name));
     }
     $adapter = $this->adaptersMap[$name];
     $class = $adapter['class'];
     // check required properties
     if (!empty($adapter['required'])) {
         foreach ($adapter['required'] as $prop) {
             if (!isset($config[$prop])) {
                 throw new InvalidConfigException(sprintf('The "%s" property must be set.', $prop));
             }
         }
     }
     switch ($name) {
         case 'local':
             return Yii::createObject($class, [$this->basePath]);
             break;
         case 'dropbox':
             return Yii::createObject($class, [Yii::createObject('Dropbox\\Client', [$config['token'], $config['app']]), isset($config['prefix']) ? $config['prefix'] : null]);
             break;
         case 'ftp':
             if (isset($config['root'])) {
                 $config['root'] = Yii::getAlias($config['root']);
             }
             break;
         case 'sftp':
             if (!isset($config['password']) && !isset($config['privateKey'])) {
                 throw new InvalidConfigException('Either "password" or "privateKey" property must be set.');
             }
             if (isset($config['root'])) {
                 $config['root'] = Yii::getAlias($config['root']);
             }
             break;
         case 'gridfs':
             return Yii::createObject($class, [(new \MongoClient($config['server']))->selectDB($config['database'])->getGridFS()]);
             break;
         case 'awss3':
             return Yii::createObject($class, [\Aws\S3\S3Client::factory($config), $config['bucket'], isset($config['prefix']) ? $config['prefix'] : null, isset($config['options']) ? $config['options'] : []]);
             break;
         case 'azure':
             return Yii::createObject($class, [\WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService(sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', base64_encode($config['accountName']), base64_encode($config['accountKey']))), $config['container']]);
             break;
         case 'copy':
             return Yii::createObject($class, [new \Barracuda\Copy\API($config['consumerKey'], $config['consumerSecret'], $config['accessToken'], $config['tokenSecret']), isset($config['prefix']) ? $config['prefix'] : null]);
             break;
         case 'rackspace':
             return Yii::createObject($class, [(new \OpenCloud\Rackspace($config['endpoint'], ['username' => $config['username'], 'apiKey' => $config['apiKey']]))->objectStoreService('cloudFiles', $config['region'])->getContainer($config['container']), isset($config['prefix']) ? $config['prefix'] : null]);
             break;
         case 'webdav':
             return Yii::createObject($class, [new \Sabre\DAV\Client($config['endpoint']), isset($config['prefix']) ? $config['prefix'] : null]);
             break;
         default:
             $class = 'League\\Flysystem\\Adapter\\NullAdapter';
             break;
     }
     return Yii::createObject($class, [$config]);
 }
 /**
  * Creates new blob REST proxy.
  *
  * @return BlobRestProxy
  */
 private static function _createBlobRestProxy()
 {
     $accountKey = getenv('CHANNEL_STORAGE_SERVICE_KEY');
     $accountName = CHANNEL_STORAGE_SERVICE_NAME;
     $blobEndpointUri = CHANNEL_URL;
     $connectionString = "BlobEndpoint={$blobEndpointUri};AccountName={$accountName};AccountKey={$accountKey}";
     return ServicesBuilder::getInstance()->createBlobService($connectionString);
 }
 public function __construct()
 {
     $this->account_name = getenv("ProjectNamiBlobCache.StorageAccount");
     $this->account_key = getenv("ProjectNamiBlobCache.StorageKey");
     $this->container = getenv("ProjectNamiBlobCache.StorageContainer");
     $this->connection_string = 'DefaultEndpointsProtocol=http;AccountName=' . $this->account_name . ';AccountKey=' . $this->account_key;
     $this->blob_service = ServicesBuilder::getInstance()->createBlobService($this->connection_string);
 }
 public function setUp()
 {
     parent::setUp();
     if (empty($GLOBALS['DOCTRINE_KEYVALUE_AZURE_NAME']) || empty($GLOBALS['DOCTRINE_KEYVALUE_AZURE_KEY'])) {
         $this->markTestSkipped("Missing Azure credentials.");
     }
     $connectionString = sprintf("DefaultEndpointsProtocol=http;AccountName=%s;AccountKey=%s", $GLOBALS['DOCTRINE_KEYVALUE_AZURE_NAME'], $GLOBALS['DOCTRINE_KEYVALUE_AZURE_KEY']);
     $tableProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
     $this->storage = new AzureSdkTableStorage($tableProxy);
 }
 /**
  * @inheritdoc
  */
 public function doCreateService(ServiceLocatorInterface $serviceLocator)
 {
     if (!class_exists('League\\Flysystem\\Azure\\AzureAdapter')) {
         throw new RequirementsException(['league/flysystem-azure'], 'Azure');
     }
     $endpoint = sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $this->options['account-name'], $this->options['account-key']);
     $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
     $adapter = new Adapter($blobRestProxy, $this->options['container']);
     return $adapter;
 }
 /**
  * Constructs CloudStorageService using the provided parameters.
  * 
  * @param string $name             The storage service name.
  * @param string $key              The storage service access key.
  * @param array  $blobEndpointUri  The blob endpoint URI.
  * @param array  $queueEndpointUri The queue endpoint URI.
  * @param array  $tableEndpointUri The queue endpoint URI.
  * 
  * @throws \InvalidArgumentException 
  */
 public function __construct($name, $key, $blobEndpointUri, $queueEndpointUri, $tableEndpointUri)
 {
     $this->_queueEndpointUri = $queueEndpointUri;
     $this->_blobEndpointUri = $blobEndpointUri;
     $this->_tableEndpointUri = $tableEndpointUri;
     $connectionString = "DefaultEndpointsProtocol=http;AccountName={$name};AccountKey={$key}";
     $this->_tableProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
     $this->_blobProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
     $this->_queueProxy = ServicesBuilder::getInstance()->createQueueService($connectionString);
 }
Beispiel #13
0
 public function __construct($SessionID)
 {
     $this->UserAuth = new UserAuth($SessionID);
     $authInfo = $this->UserAuth->checkUserSession();
     if ($authInfo[0]) {
         $this->Email = $authInfo[1];
         //Replace with account key
         $ConnectionString = "DefaultEndpointsProtocol=https;AccountName=urimg;AccountKey=XXXXXXXXX;";
         $this->blobRestProxy = ServicesBuilder::getInstance()->createBlobService($ConnectionString);
     }
 }
Beispiel #14
0
 /**
  * Returns the file system provider
  *
  * @return \League\Flysystem\FilesystemInterface File system provider
  */
 protected function getProvider()
 {
     if (!isset($this->fs)) {
         $config = $this->getConfig();
         if (!isset($config['endpoint'])) {
             throw new Exception(sprintf('Configuration option "%1$s" missing', 'endpoint'));
         }
         if (!isset($config['container'])) {
             throw new Exception(sprintf('Configuration option "%1$s" missing', 'container'));
         }
         $service = ServicesBuilder::getInstance()->createBlobService($config['endpoint']);
         $this->fs = new Filesystem(new AzureAdapter($service, $config['container']));
     }
     return $this->fs;
 }
Beispiel #15
0
 public function actionAdd()
 {
     if (VF::app()->is_admin || isset($_GET['key']) && $_GET['key'] == 'eb4db0c51005d73ae57064be10c17145') {
         $new_id = 0;
         if (isset($_POST['title'])) {
             $title = trim(mysql_real_escape_string($_POST['title']));
             $lang_id = (int) $_POST['lang_id'];
             $category_id = (int) $_POST['category_id'];
             $holiday_id = (int) $_POST['holiday_id'];
             $instructions = trim(mysql_real_escape_string($_POST['instructions']));
             $prep_time = trim(mysql_real_escape_string($_POST['prep_time']));
             $cook_time = trim(mysql_real_escape_string($_POST['cook_time']));
             $total_time = trim(mysql_real_escape_string($_POST['total_time']));
             $ingredients = $_POST['ingredient'];
             $blob_name = '';
             if (!empty($_FILES['image']['tmp_name'])) {
                 $connectionString = "DefaultEndpointsProtocol=http;AccountName=trecipes;AccountKey=FoleK8mHGV5MaOvnJaZV6MFD7WadIEc12SL5hhwj7h949ysaXcp7VeTHimfQt6qxSwdQIEVkba0NQ/o58cgdXw==";
                 // Create blob REST proxy.
                 $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
                 $options = new CreateBlobOptions();
                 $options->setBlobContentType("image/jpeg");
                 $blob_name = md5(time()) . ".jpg";
                 system("convert " . $_FILES['image']['tmp_name'] . " -resize 200x200 " . $_FILES['image']['tmp_name']);
                 $content = fopen($_FILES['image']['tmp_name'], "r");
                 $blobRestProxy->createBlockBlob("previews", $blob_name, $content, $options);
                 $blob_name = "http://s1.resepte.net/previews/{$blob_name}";
             }
             VF::app()->database->query("INSERT INTO recipes (title, image_url, image_mobile_url, category_id, instructions, lang_id,\n                prep_time, cook_time, total_time, holiday_id) VALUES ('{$title}', '{$blob_name}', '', {$category_id}, '{$instructions}', '{$lang_id}', '{$prep_time}', '{$cook_time}', '{$total_time}', {$holiday_id})\n                ");
             $new_id = VF::app()->database->getLastId();
             if ($new_id > 0) {
                 foreach ($ingredients as $i => $ing) {
                     $ing = mysql_real_escape_string(trim($ing));
                     if (!empty($ing)) {
                         $i_id = VF::app()->database->sql("SELECT id FROM `ingredients` WHERE name = '{$ing}'")->queryRow();
                         $i_id = (int) $i_id['id'];
                         if ($i_id == 0) {
                             VF::app()->database->query("INSERT INTO `ingredients` (name, lang_id) VALUES ('{$ing}', {$lang_id})");
                             $i_id = VF::app()->database->getLastId();
                         }
                         $amount = mysql_real_escape_string(trim($_POST['ingredient_append'][$i]));
                         VF::app()->database->query("INSERT INTO recipes2ingredients (recipe_id, ingredient_id, append) VALUES ('{$new_id}', '{$i_id}', '{$amount}')");
                     }
                 }
             }
         }
         $this->render('add', array('new_id' => $new_id));
     }
 }
Beispiel #16
0
 public function fetchstl_ajax()
 {
     require_once "/application/third_party/WindowsAzure/WindowsAzure.php";
     $connectionString = "DefaultEndpointsProtocol=https;AccountName=zeepro;AccountKey=h+1YL4YpN64VfR21SUeWyfM2MyNZI9X08Cwi9WSFAjLnJAGDsxcRLsuQSGZX6Ibe3/VtJKUi7x9lvZOyI7RI+w==";
     try {
         $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
         $blob = $blobRestProxy->getBlob("printstlapi", $this->input->get('token'));
         $this->load->helper('download');
         force_download('rendering.stl', stream_get_contents($blob->getContentStream()));
     } catch (ServiceException $e) {
         //			ZLog("Error", $e->getCode(), $e->getMessage());
         //			$this->output->set_status_header(404);
         echo "Error:" . $e->getCode() . $e->getMessage();
     }
     return;
 }
Beispiel #17
0
 protected function getBlobService()
 {
     if (!$this->service) {
         $endpoint = Config::get('storage.endpoint_protocol', 'https');
         $account = Config::get('storage.account');
         if (!$account) {
             throw new Exception(__CLASS__ . ": 'storage.account' config is required.");
         }
         $key = Config::get('storage.key');
         if (!$key) {
             throw new Exception(__CLASS__ . ": 'storage.key' config is required.");
         }
         $conection = array("DefaultEndpointsProtocol={$endpoint}", "AccountName={$account}", "AccountKey={$key}");
         $this->service = ServicesBuilder::getInstance()->createBlobService(join(";", $conection));
     }
     return $this->service;
 }
 /**
  * @return int
  */
 protected function fire()
 {
     $connectionString = "DefaultEndpointsProtocol=https;AccountName=" . $this->input->getArgument('AccountName') . ";AccountKey=" . $this->input->getArgument('AccountKey');
     /** @var \WindowsAzure\Table\TableRestProxy $tableRestProxy */
     $this->tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
     $this->identifyTableName();
     $result = $this->getQueryResult("Timestamp le datetime'2016-01-12T16:12:59' and Timestamp ge datetime'2016-01-12T16:02:59'");
     if (!$result instanceof QueryEntitiesResult) {
         return $result;
     }
     $entities = $result->getEntities();
     $n = 1;
     /** @var Entity $entity */
     foreach ($entities as $entity) {
         $props = $entity->getProperties();
         $vmName = $this->getVirtualMachineNameFromPartitionKey($entity->getPartitionKey());
         $this->output->writeln($vmName . ' [' . $entity->getTimestamp()->format('d-m-Y H:i:s') . ']' . '<info>' . $entity->getPropertyValue('CounterName') . '</info> : <comment>' . $entity->getPropertyValue('Last') . '</comment>');
     }
     $this->info(count($entities) . 'rows');
 }
 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 />";
     }
 }
Beispiel #20
0
 public function __construct($connectionString, $container, $url)
 {
     $this->blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
     $this->container = $container;
     $this->url = $url;
 }
<?php

require_once 'vendor\\autoload.php';
ini_set('display_errors', 1);
error_reporting(~0);
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=xecondemo01;AccountKey=<어카운트키>";
// REST proxy 생성
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$content = fopen("azure_center.png", "r");
//파일 접근 권한 주의 fopen 참조
$blob_name = "xeconblob";
// blob 이름 지정
try {
    //Upload blob
    $blobRestProxy->createBlockBlob("xecondevcontainer", $blob_name, $content);
} catch (ServiceException $e) {
    // Handle exception based on error codes and messages.
    // Error codes and messages are here:
    // http://msdn.microsoft.com/library/azure/dd179439.aspx
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code . ": " . $error_message . "<br />";
}
<?php

require_once 'vendor\\autoload.php';
ini_set('display_errors', 1);
error_reporting(~0);
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
use WindowsAzure\Table\Models\Entity;
//추가
use WindowsAzure\Table\Models\EdmType;
//추가
// Storage의 connection string 제공
$connectionString = "DefaultEndpointsProtocol=http;AccountName=vstechupdate;AccountKey=<어카운트키>";
// Azure의 table storage를 위한 REST proxy 생성
$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
/////////////////////////////////////////////////////////////////
// 02 테이블에 엔터티 추가
/////////////////////////////////////////////////////////////////
//rowkey를 위해 guid 생성
function getGUID()
{
    if (function_exists('com_create_guid')) {
        return com_create_guid();
    } else {
        mt_srand((double) microtime() * 10000);
        //optional for php 4.2.0 and up.
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $hyphen = chr(45);
        // "-"
        $uuid = chr(123) . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12) . chr(125);
        // "}"
 /**
  * Get the azure client.
  *
  * @param string[] $auth
  *
  * @return \WindowsAzure\Blob\Internal\IBlob
  */
 protected function getClient(array $auth)
 {
     $endpoint = sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $auth['account-name'], $auth['api-key']);
     return ServicesBuilder::getInstance()->createBlobService($endpoint);
 }
 /**
  * Initializes new CloudSubscription object using the provided parameters.
  *
  * @param string $subscriptionId  The Windows Azure subscription id.
  * @param string $certificatePath The registered certificate.
  */
 public function __construct($subscriptionId, $certificatePath)
 {
     $connectionString = "SubscriptionID={$subscriptionId};CertificatePath={$certificatePath}";
     $this->_proxy = ServicesBuilder::getInstance()->createServiceManagementService($connectionString);
 }
 /**
  * Create blob storage client using Azure SDK for PHP
  *
  * @param string $accountName   Windows Azure Storage account name
  *
  * @param string $accountKey    Windows Azure Storage account primary key
  *
  * @param string $proxyHost     Http proxy host
  *
  * @param string $proxyPort     Http proxy port
  *
  * @param string $proxyUserName Http proxy user name
  *
  * @param string $proxyPassword Http proxy password
  *
  * @return WindowsAzure\Blob\BlobRestProxy Blob storage client
  */
 public static function getStorageClient($accountName = null, $accountKey = null, $proxyHost = null, $proxyPort = null, $proxyUserName = null, $proxyPassword = null)
 {
     // Storage Account Settings from db
     $storageAccountName = WindowsAzureStorageUtil::getAccountName();
     $storageAccountKey = WindowsAzureStorageUtil::getAccountKey();
     $httpProxyHost = WindowsAzureStorageUtil::getHttpProxyHost();
     $httpProxyPort = WindowsAzureStorageUtil::getHttpProxyPort();
     $httpProxyUserName = WindowsAzureStorageUtil::getHttpProxyUserName();
     $httpProxyPassword = WindowsAzureStorageUtil::getHttpProxyPassword();
     // Parameters take precedence over settings in the db
     if ($accountName) {
         $storageAccountName = $accountName;
         $storageAccountKey = $accountKey;
         $httpProxyHost = $proxyHost;
         $httpProxyPort = $proxyPort;
         $httpProxyUserName = $proxyUserName;
         $httpProxyPassword = $proxyPassword;
     }
     $azureServiceConnectionString = null;
     if ('devstoreaccount1' === $storageAccountName) {
         // Use development storage
         $azureServiceConnectionString = "UseDevelopmentStorage=true";
     } else {
         // Use cloud storage
         $azureServiceConnectionString = "DefaultEndpointsProtocol=http" . ";AccountName=" . $storageAccountName . ";AccountKey=" . $storageAccountKey;
     }
     $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($azureServiceConnectionString);
     $httpProxyHost = $httpProxyHost;
     if (!empty($httpProxyHost)) {
         $proxyFilter = new WindowsAzureStorageProxyFilter($httpProxyHost, $httpProxyPort, $httpProxyUserName, $httpProxyPassword);
         $blobRestProxy = $blobRestProxy->withFilter($proxyFilter);
     }
     return $blobRestProxy;
 }
 /**
  * Establish a queue connection.
  *
  * @param  array $config
  *
  * @return \Illuminate\Queue\QueueInterface
  */
 public function connect(array $config)
 {
     $connectionString = 'Endpoint=' . $config['endpoint'] . ';SharedSecretIssuer=' . $config['secretissuer'] . ';SharedSecretValue=' . $config['secret'];
     $serviceBusRestProxy = ServicesBuilder::getInstance()->createServiceBusService($connectionString);
     return new AzureQueue($serviceBusRestProxy, $config['queue']);
 }
 /**
  * @return AzureAdapter
  */
 protected function prepareAdapter()
 {
     return new AzureAdapter(ServicesBuilder::getInstance()->createBlobService(sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', base64_encode($this->accountName), base64_encode($this->accountKey))), $this->container);
 }
 /**
  * @covers WindowsAzure\Common\ServicesBuilder::getInstance
  */
 public function testGetInstance()
 {
     // Test
     $actual = ServicesBuilder::getInstance();
     // Assert
     $this->assertInstanceOf('WindowsAzure\\Common\\ServicesBuilder', $actual);
 }
 /**
  * Testing connection with Microsoft Azure Media Services
  * @param string $wams_account_name Media Service Account Name
  * @param string $wams_access_key Primary Media Service access key
  * @throws KalturaAPIException If Microsoft Azure credentials not defined
  */
 public static function testConnection($wams_account_name, $wams_access_key)
 {
     if (empty($wams_account_name) || empty($wams_access_key)) {
         throw new KalturaAPIException(KalturaErrors::WAMS_CREDENTIALS_REQUIRED);
     }
     $mediaServiceProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($wams_account_name, $wams_access_key));
     try {
         $mediaServiceProxy->getAssetList();
     } catch (Exception $e) {
         self::handleException($e);
     }
 }
 *
 * @author    Azure PHP SDK <*****@*****.**>
 * @copyright 2012 Microsoft Corporation
 * @license   http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 *
 * @link      https://github.com/windowsazure/azure-sdk-for-php
 */
require_once __DIR__ . '/../vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\Internal\MediaServicesSettings;
use WindowsAzure\MediaServices\Models\EncodingReservedUnitType;
// read user settings from config
include_once 'userconfig.php';
$reservedUnits = 1;
$reservedUnitsType = EncodingReservedUnitType::S1;
$types = array('S1', 'S2', 'S3');
echo "Azure SDK for PHP - Scale Encoding Units Sample" . PHP_EOL;
// 1. set up the MediaServicesService object to call into the Media Services REST API
$restProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($account, $secret));
// 2. retrieve the current configuration of Encoding Units
$encodingUnits = $restProxy->getEncodingReservedUnit();
echo 'Current Encoding Reserved Units: ' . $encodingUnits->getCurrentReservedUnits() . ' units (' . $types[$encodingUnits->getReservedUnitType()] . ")" . PHP_EOL;
echo 'Updating to: ' . $reservedUnits . ' units (' . $types[$reservedUnitsType] . ') ...';
// 3. set up the new encoding units settings
$encodingUnits->setCurrentReservedUnits($reservedUnits);
$encodingUnits->setReservedUnitType($reservedUnitsType);
// 4. update the encoding reserved units
$restProxy->updateEncodingReservedUnit($encodingUnits);
// 5. reload the current configuration and show the results
$encodingUnits = $restProxy->getEncodingReservedUnit();
echo PHP_EOL . "Updated Encoding Reserved Units: " . $encodingUnits->getCurrentReservedUnits() . ' units (' . $types[$encodingUnits->getReservedUnitType()] . ")" . PHP_EOL;