/** * @covers WindowsAzure\Common\CloudConfigurationManager::unregisterSource * @covers WindowsAzure\Common\CloudConfigurationManager::_init */ public function testUnRegisterSourceWithDefaultSource() { // Setup $expectedKey = $this->_key; $expectedValue = $this->_value . "extravalue4"; $name = 'my_source'; CloudConfigurationManager::registerSource($name, function ($key) use($expectedKey, $expectedValue) { if ($key == $expectedKey) { return $expectedValue; } }); // Test $callback = CloudConfigurationManager::unregisterSource(ConnectionStringSource::ENVIRONMENT_SOURCE); // Assert $actual = CloudConfigurationManager::getConnectionString($expectedKey); $this->assertEquals($expectedValue, $actual); $this->assertNotNull($callback); }
environment variable through a technique such as set StorageConnectionString=DefaultEndpointsProtocol=http;AccountName=your_account_name;AccountKey=your_account_key (Substitute your storage account name and account key for your_account_name and your_account_key, respectively.) Then run this sample at a command prompt that has the StorageConnectionString as an active environment variable. The format for the storage connection string itself is documented at http://msdn.microsoft.com/en-us/library/windowsazure/ee758697.aspx If you do not want to use an environment variable as the source for the connection string name, you can register other sources via the CloudCofigurationManager::registerSource method. */ $connectionString = CloudConfigurationManager::getConnectionString("StorageConnectionString"); if (null == $connectionString || "" == $connectionString) { echo "Did not find a connection string whose name is 'StorageConnectionString'."; exit; } $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); createContainerIfNotExists($blobRestProxy); echo "Using the '" . CONTAINERNAME . "' container and the '" . PAGEBLOBNAME . "' blob.\n"; $createBlobPagesOptions = new CreateBlobPagesOptions(); // Create the page blob. createPageBlob($blobRestProxy); waitForEnterKey(); // Show active ranges (there won't be any for a newly created blob). showActiveRanges($blobRestProxy); waitForEnterKey(); // Write to the blob, using the third page. The page index is zero-based.