Source for file Client.php
Documentation is available at Client.php
* Copyright (c) 2009 - 2010, RealDolmen
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of RealDolmen nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2010, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
* @version $Id: Storage.php 51671 2010-09-30 08:33:45Z unknown $
* @see Microsoft_AutoLoader
require_once dirname(__FILE__ ) . '/../../AutoLoader.php';
* @package Microsoft_WindowsAzure
* @copyright Copyright (c) 2009 - 2010, RealDolmen (http://www.realdolmen.com)
* @license http://phpazure.codeplex.com/license
const URL_MANAGEMENT = "https://management.core.windows.net";
const OP_OPERATIONS = "operations";
const OP_STORAGE_ACCOUNTS = "services/storageservices";
const OP_HOSTED_SERVICES = "services/hostedservices";
const OP_AFFINITYGROUPS = "affinitygroups";
const OP_LOCATIONS = "locations";
const OP_OPERATINGSYSTEMS = "operatingsystems";
const OP_OPERATINGSYSTEMFAMILIES = "operatingsystemfamilies";
* Management certificate path (.PEM)
* Management certificate passphrase
* Microsoft_Http_Client channel used for communication with REST services
* @var Microsoft_Http_Client
* Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract instance
* @var Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract
* Returns the last request ID
* Creates a new Microsoft_WindowsAzure_Management instance
* @param string $subscriptionId Subscription ID
* @param string $certificatePath Management certificate path (.PEM)
* @param string $certificatePassphrase Management certificate passphrase
* @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null
// Setup default Microsoft_Http_Client channel
'adapter' => 'Microsoft_Http_Client_Adapter_Socket',
// Set cURL options if cURL is used afterwards
$options['curloptions'] = array(
CURLOPT_FOLLOWLOCATION => true,
* Set the HTTP client channel to use
* @param Microsoft_Http_Client_Adapter_Interface|string$adapterInstance Adapter instance or adapter class name.
* Retrieve HTTP client channel
* @return Microsoft_Http_Client_Adapter_Interface
* Returns the Windows Azure subscription ID
* Returns the last request ID.
* Get base URL for creating requests
* Perform request using Microsoft_Http_Client channel
* @param string $path Path
* @param string $queryString Query string
* @param string $httpVerb HTTP verb the request will use
* @param array $headers x-ms headers to add
* @param mixed $rawData Optional RAW HTTP data to be sent over the wire
* @return Microsoft_Http_Response
$httpVerb = Microsoft_Http_Client::GET,
if (strpos($path, '/') !== 0) {
// Ensure cUrl will also work correctly:
// - disable Content-Type if required
// - disable Expect: 100 Continue
if (!isset ($headers["Content-Type"])) {
$headers["Content-Type"] = '';
//$headers["Expect"] = '';
$path = self::urlencode($path);
$queryString = self::urlencode($queryString);
// Generate URL and sign request
$requestUrl = $this->getBaseUrl() . $path . $queryString;
$requestHeaders = $headers;
* Parse result from Microsoft_Http_Response
* @param Microsoft_Http_Response $response Response from HTTP call
* @throws Microsoft_WindowsAzure_Exception
protected function _parseResponse(Microsoft_Http_Response $response = null)
$namespaces = array_merge($xml->getNamespaces(true), $xml->getDocNamespaces(true));
// Register all namespace prefixes
foreach ($namespaces as $prefix => $ns) {
$xml->registerXPathNamespace($prefix, $ns);
* @param string $value Value to encode
* @return string Encoded value
* Builds a query string from an array of elements
* @param array Array of elements
* @return string Assembled query string
return count($queryString) > 0 ? '?' . implode('&', $queryString) : '';
* Get error message from Microsoft_Http_Response
* @param Microsoft_Http_Response $response Repsonse
* @param string $alternativeError Alternative error message
protected function _getErrorMessage(Microsoft_Http_Response $response, $alternativeError = 'Unknown error.')
if ($response && $response->Message) {
return (string) $response->Message;
return $alternativeError;
* The Get Operation Status operation returns the status of the specified operation.
* After calling an asynchronous operation, you can call Get Operation Status to
* determine whether the operation has succeed, failed, or is still in progress.
* @param string $requestId The request ID. If omitted, the last request ID will be used.
* @return Microsoft_WindowsAzure_Management_OperationStatusInstance
* @throws Microsoft_WindowsAzure_Management_Exception
$response = $this->_performRequest(self::OP_OPERATIONS . '/' . $requestId);
if ($response->isSuccessful()) {
($result->Error ? (string) $result->Error->Code : ''),
($result->Error ? (string) $result->Error->Message : '')
* The List Subscription Operations operation returns a list of create, update,
* and delete operations that were performed on a subscription during the specified timeframe.
* Documentation on the parameters can be found at http://msdn.microsoft.com/en-us/library/gg715318.aspx.
* @param string $startTime The start of the timeframe to begin listing subscription operations in UTC format. This parameter and the $endTime parameter indicate the timeframe to retrieve subscription operations. This parameter cannot indicate a start date of more than 90 days in the past.
* @param string $endTime The end of the timeframe to begin listing subscription operations in UTC format. This parameter and the $startTime parameter indicate the timeframe to retrieve subscription operations.
* @param string $objectIdFilter Returns subscription operations only for the specified object type and object ID.
* @param string $operationResultFilter Returns subscription operations only for the specified result status, either Succeeded, Failed, or InProgress.
* @param string $continuationToken Internal usage.
* @return array Array of Microsoft_WindowsAzure_Management_SubscriptionOperationInstance
* @throws Microsoft_WindowsAzure_Management_Exception
public function listSubscriptionOperations($startTime, $endTime, $objectIdFilter = null, $operationResultFilter = null, $continuationToken = null)
if ($startTime == '' || is_null($startTime)) {
if ($endTime == '' || is_null($endTime)) {
if ($operationResultFilter != '' && !is_null($operationResultFilter)) {
$operationResultFilter = strtolower($operationResultFilter);
if ($operationResultFilter != 'succeeded' && $operationResultFilter != 'failed' && $operationResultFilter != 'inprogress') {
$parameters[] = 'StartTime=' . $startTime;
$parameters[] = 'EndTime=' . $endTime;
if ($objectIdFilter != '' && !is_null($objectIdFilter)) {
$parameters[] = 'ObjectIdFilter=' . $objectIdFilter;
if ($operationResultFilter != '' && !is_null($operationResultFilter)) {
$parameters[] = 'OperationResultFilter=' . ucfirst($operationResultFilter);
if ($continuationToken != '' && !is_null($continuationToken)) {
$parameters[] = 'ContinuationToken=' . $continuationToken;
if ($response->isSuccessful()) {
$namespaces = $result->getDocNamespaces();
$result->registerXPathNamespace('__empty_ns', $namespaces['']);
$xmlOperations = $result->xpath('//__empty_ns:SubscriptionOperation');
foreach ($xmlOperations as $xmlOperation) {
// Create operation instance
$xmlOperation->OperationId,
$xmlOperation->OperationObjectId,
$xmlOperation->OperationName,
(array) $xmlOperation->OperationCaller,
(array) $xmlOperation->OperationStatus
$xmlOperation->registerXPathNamespace('__empty_ns', $namespaces['']);
$xmlParameters = $xmlOperation->xpath('.//__empty_ns:OperationParameter');
foreach ($xmlParameters as $xmlParameter) {
$xmlParameterDetails = $xmlParameter->children('http://schemas.datacontract.org/2004/07/Microsoft.Samples.WindowsAzure.ServiceManagement');
$operation->addOperationParameter((string) $xmlParameterDetails->Name, (string) $xmlParameterDetails->Value);
$returnValue[] = $operation;
if (!is_null($result->ContinuationToken) && $result->ContinuationToken != '') {
* Wait for an operation to complete
* @param string $requestId The request ID. If omitted, the last request ID will be used.
* @param int $sleepInterval Sleep interval in milliseconds.
* @return Microsoft_WindowsAzure_Management_OperationStatusInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($requestId == '' || is_null($requestId)) {
while ($status->Status == 'InProgress') {
* Creates a new Microsoft_WindowsAzure_Storage_Blob instance for the current account
* @param string $serviceName the service name to create a storage client for.
* @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
* @return Microsoft_WindowsAzure_Storage_Blob
public function createBlobClientForService($serviceName, Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy = null)
if ($serviceName == '' || is_null($serviceName)) {
* Creates a new Microsoft_WindowsAzure_Storage_Table instance for the current account
* @param string $serviceName the service name to create a storage client for.
* @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
* @return Microsoft_WindowsAzure_Storage_Table
if ($serviceName == '' || is_null($serviceName)) {
* Creates a new Microsoft_WindowsAzure_Storage_Queue instance for the current account
* @param string $serviceName the service name to create a storage client for.
* @param Microsoft_WindowsAzure_RetryPolicy_RetryPolicyAbstract $retryPolicy Retry policy to use when making requests
* @return Microsoft_WindowsAzure_Storage_Queue
if ($serviceName == '' || is_null($serviceName)) {
* The List Storage Accounts operation lists the storage accounts available under
* the current subscription.
* @return array An array of Microsoft_WindowsAzure_Management_StorageServiceInstance
if ($response->isSuccessful()) {
if (!$result->StorageService) {
if (count($result->StorageService) > 1) {
$xmlServices = $result->StorageService;
$xmlServices = array($result->StorageService);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Url,
(string) $xmlServices[$i]->ServiceName
* The Get Storage Account Properties operation returns the system properties for the
* specified storage account. These properties include: the address, description, and
* label of the storage account; and the name of the affinity group to which the service
* belongs, or its geo-location if it is not part of an affinity group.
* @param string $serviceName The name of your service.
* @return Microsoft_WindowsAzure_Management_StorageServiceInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
$response = $this->_performRequest(self::OP_STORAGE_ACCOUNTS . '/' . $serviceName);
if ($response->isSuccessful()) {
(string) $xmlService->Url,
(string) $xmlService->ServiceName,
(string) $xmlService->StorageServiceProperties->Description,
(string) $xmlService->StorageServiceProperties->AffinityGroup,
(string) $xmlService->StorageServiceProperties->Location,
(string) $xmlService->StorageServiceProperties->Label
* The Get Storage Keys operation returns the primary
* and secondary access keys for the specified storage account.
* @param string $serviceName The name of your service.
* @return array An array of strings
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
$response = $this->_performRequest(self::OP_STORAGE_ACCOUNTS . '/' . $serviceName . '/keys');
if ($response->isSuccessful()) {
(string) $xmlService->StorageServiceKeys->Primary,
(string) $xmlService->StorageServiceKeys->Secondary
* The Regenerate Keys operation regenerates the primary
* or secondary access key for the specified storage account.
* @param string $serviceName The name of your service.
* @param string $key The key to regenerate (primary or secondary)
* @return array An array of strings
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($key != 'primary' && $key != 'secondary') {
self::OP_STORAGE_ACCOUNTS . '/' . $serviceName . '/keys', '?action=regenerate',
array('Content-Type' => 'application/xml'),
'<?xml version="1.0" encoding="utf-8"?>
<RegenerateKeys xmlns="http://schemas.microsoft.com/windowsazure">
<KeyType>' . ucfirst($key) . '</KeyType>
if ($response->isSuccessful()) {
(string) $xmlService->StorageServiceKeys->Primary,
(string) $xmlService->StorageServiceKeys->Secondary
* The List Hosted Services operation lists the hosted services available
* under the current subscription.
* @return array An array of Microsoft_WindowsAzure_Management_HostedServiceInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
if (!$result->HostedService) {
if (count($result->HostedService) > 1) {
$xmlServices = $result->HostedService;
$xmlServices = array($result->HostedService);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Url,
(string) $xmlServices[$i]->ServiceName
* The Create Hosted Service operation creates a new hosted service in Windows Azure.
* @param string $serviceName A name for the hosted service that is unique to the subscription.
* @param string $label A label for the hosted service. The label may be up to 100 characters in length.
* @param string $description A description for the hosted service. The description may be up to 1024 characters in length.
* @param string $location Required if AffinityGroup is not specified. The location where the hosted service will be created.
* @param string $affinityGroup Required if Location is not specified. The name of an existing affinity group associated with this subscription.
public function createHostedService($serviceName, $label, $description = '', $location = null, $affinityGroup = null)
if ($serviceName == '' || is_null($serviceName)) {
if ($label == '' || is_null($label)) {
if (strlen($description) > 1024) {
$locationOrAffinityGroup = is_null($location)
? '<AffinityGroup>' . $affinityGroup . '</AffinityGroup>'
: '<Location>' . $location . '</Location>';
array('Content-Type' => 'application/xml; charset=utf-8'),
'<CreateHostedService xmlns="http://schemas.microsoft.com/windowsazure"><ServiceName>' . $serviceName . '</ServiceName><Label>' . base64_encode($label) . '</Label><Description>' . $description . '</Description>' . $locationOrAffinityGroup . '</CreateHostedService>');
if (!$response->isSuccessful()) {
* The Update Hosted Service operation updates the label and/or the description for a hosted service in Windows Azure.
* @param string $serviceName A name for the hosted service that is unique to the subscription.
* @param string $label A label for the hosted service. The label may be up to 100 characters in length.
* @param string $description A description for the hosted service. The description may be up to 1024 characters in length.
if ($serviceName == '' || is_null($serviceName)) {
if ($label == '' || is_null($label)) {
$response = $this->_performRequest(self::OP_HOSTED_SERVICES . '/' . $serviceName, '',
array('Content-Type' => 'application/xml; charset=utf-8'),
'<UpdateHostedService xmlns="http://schemas.microsoft.com/windowsazure"><Label>' . base64_encode($label) . '</Label><Description>' . $description . '</Description></UpdateHostedService>');
if (!$response->isSuccessful()) {
* The Delete Hosted Service operation deletes the specified hosted service in Windows Azure.
* @param string $serviceName A name for the hosted service that is unique to the subscription.
if ($serviceName == '' || is_null($serviceName)) {
if (!$response->isSuccessful()) {
* The Get Hosted Service Properties operation retrieves system properties
* for the specified hosted service. These properties include the service
* name and service type; the name of the affinity group to which the service
* belongs, or its location if it is not part of an affinity group; and
* optionally, information on the service's deployments.
* @param string $serviceName The name of your service.
* @return Microsoft_WindowsAzure_Management_HostedServiceInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
$response = $this->_performRequest(self::OP_HOSTED_SERVICES . '/' . $serviceName, '?embed-detail=true');
if ($response->isSuccessful()) {
(string) $xmlService->Url,
(string) $xmlService->ServiceName,
(string) $xmlService->HostedServiceProperties->Description,
(string) $xmlService->HostedServiceProperties->AffinityGroup,
(string) $xmlService->HostedServiceProperties->Location,
(string) $xmlService->HostedServiceProperties->Label
if (count($xmlService->Deployments->Deployment) > 1) {
$xmlServices = $xmlService->Deployments->Deployment;
$xmlServices = array($xmlService->Deployments->Deployment);
foreach ($xmlServices as $xmlDeployment) {
$returnValue->Deployments = $deployments;
* The Create Deployment operation uploads a new service package
* and creates a new deployment on staging or production.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $name The name for the deployment. The deployment ID as listed on the Windows Azure management portal must be unique among other deployments for the hosted service.
* @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
* @param string $packageUrl The service configuration file for the deployment.
* @param string $configuration A label for this deployment, up to 100 characters in length.
* @param boolean $startDeployment Indicates whether to start the deployment immediately after it is created.
* @param boolean $treatWarningsAsErrors Indicates whether to treat package validation warnings as errors.
* @throws Microsoft_WindowsAzure_Management_Exception
public function createDeployment($serviceName, $deploymentSlot, $name, $label, $packageUrl, $configuration, $startDeployment = false, $treatWarningsAsErrors = false)
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($name == '' || is_null($name)) {
if ($label == '' || is_null($label)) {
if ($packageUrl == '' || is_null($packageUrl)) {
if ($configuration == '' || is_null($configuration)) {
// Clean up the configuration
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
array('Content-Type' => 'application/xml; charset=utf-8'),
'<CreateDeployment xmlns="http://schemas.microsoft.com/windowsazure"><Name>' . $name . '</Name><PackageUrl>' . $packageUrl . '</PackageUrl><Label>' . base64_encode($label) . '</Label><Configuration>' . base64_encode($conformingConfiguration) . '</Configuration><StartDeployment>' . ($startDeployment ? 'true' : 'false') . '</StartDeployment><TreatWarningsAsError>' . ($treatWarningsAsErrors ? 'true' : 'false') . '</TreatWarningsAsError></CreateDeployment>');
if (!$response->isSuccessful()) {
* The Get Deployment operation returns configuration information, status,
* and system properties for the specified deployment.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @return Microsoft_WindowsAzure_Management_DeploymentInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
* The Get Deployment operation returns configuration information, status,
* and system properties for the specified deployment.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @return Microsoft_WindowsAzure_Management_DeploymentInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
* The Get Deployment operation returns configuration information, status,
* and system properties for the specified deployment.
* @param string $operationUrl The operation url
* @return Microsoft_WindowsAzure_Management_DeploymentInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
* The Swap Deployment operation initiates a virtual IP swap between
* the staging and production deployment environments for a service.
* If the service is currently running in the staging environment,
* it will be swapped to the production environment. If it is running
* in the production environment, it will be swapped to staging.
* @param string $serviceName The service name.
* @param string $productionDeploymentName The name of the production deployment.
* @param string $sourceDeploymentName The name of the source deployment.
* @throws Microsoft_WindowsAzure_Management_Exception
public function swapDeployment($serviceName, $productionDeploymentName, $sourceDeploymentName)
if ($serviceName == '' || is_null($serviceName)) {
if ($productionDeploymentName == '' || is_null($productionDeploymentName)) {
if ($sourceDeploymentName == '' || is_null($sourceDeploymentName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName;
array('Content-Type' => 'application/xml; charset=utf-8'),
'<Swap xmlns="http://schemas.microsoft.com/windowsazure"><Production>' . $productionDeploymentName . '</Production><SourceDeployment>' . $sourceDeploymentName . '</SourceDeployment></Swap>');
if (!$response->isSuccessful()) {
* The Delete Deployment operation deletes the specified deployment.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
* The Delete Deployment operation deletes the specified deployment.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
* The Delete Deployment operation deletes the specified deployment.
* @param string $operationUrl The operation url
* @throws Microsoft_WindowsAzure_Management_Exception
if (!$response->isSuccessful()) {
* The Update Deployment Status operation initiates a change in deployment status.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $status The deployment status (running|suspended)
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($status != 'running' && $status != 'suspended') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
* The Update Deployment Status operation initiates a change in deployment status.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param string $status The deployment status (running|suspended)
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($status != 'running' && $status != 'suspended') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
* The Update Deployment Status operation initiates a change in deployment status.
* @param string $operationUrl The operation url
* @param string $status The deployment status (running|suspended)
* @throws Microsoft_WindowsAzure_Management_Exception
array('Content-Type' => 'application/xml; charset=utf-8'),
'<UpdateDeploymentStatus xmlns="http://schemas.microsoft.com/windowsazure"><Status>' . ucfirst($status) . '</Status></UpdateDeploymentStatus>');
if (!$response->isSuccessful()) {
* Converts an XmlElement into a Microsoft_WindowsAzure_Management_DeploymentInstance
* @param object $xmlService The XML Element
* @return Microsoft_WindowsAzure_Management_DeploymentInstance
* @throws Microsoft_WindowsAzure_Management_Exception
(string) $xmlService->Name,
(string) $xmlService->DeploymentSlot,
(string) $xmlService->PrivateID,
(string) $xmlService->Label,
(string) $xmlService->Url,
(string) $xmlService->Configuration,
(string) $xmlService->Status,
(string) $xmlService->UpgradeStatus,
(string) $xmlService->UpgradeType,
(string) $xmlService->CurrentUpgradeDomainState,
(string) $xmlService->CurrentUpgradeDomain,
(string) $xmlService->UpgradeDomainCount
if ($xmlService->RoleInstanceList && $xmlService->RoleInstanceList->RoleInstance) {
$xmlRoleInstances = $xmlService->RoleInstanceList->RoleInstance;
if (count($xmlService->RoleInstanceList->RoleInstance) == 1) {
$xmlRoleInstances = array($xmlService->RoleInstanceList->RoleInstance);
$roleInstances = array();
for ($i = 0; $i < count($xmlRoleInstances); $i++ ) {
$roleInstances[] = array(
'rolename' => (string) $xmlRoleInstances[$i]->RoleName,
'instancename' => (string) $xmlRoleInstances[$i]->InstanceName,
'instancestatus' => (string) $xmlRoleInstances[$i]->InstanceStatus
$returnValue->RoleInstanceList = $roleInstances;
if ($xmlService->RoleList && $xmlService->RoleList->Role) {
$xmlRoles = $xmlService->RoleList->Role;
if (count($xmlService->RoleList->Role) == 1) {
$xmlRoles = array($xmlService->RoleList->Role);
for ($i = 0; $i < count($xmlRoles); $i++ ) {
'rolename' => (string) $xmlRoles[$i]->RoleName,
'osversion' => (!is_null($xmlRoles[$i]->OsVersion) ? (string) $xmlRoles[$i]->OsVersion : (string) $xmlRoles[$i]->OperatingSystemVersion)
$returnValue->RoleList = $roles;
* Updates a deployment's role instance count.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string|array$roleName The role name
* @param string|array$instanceCount The instance count
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($roleName == '' || is_null($roleName)) {
$configuration = $deployment->Configuration;
* Updates a deployment's role instance count.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string|array$roleName The role name
* @param string|array$instanceCount The instance count
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($roleName == '' || is_null($roleName)) {
$configuration = $deployment->Configuration;
* Updates instance count in configuration XML.
* @param string|array$roleName The role name
* @param string|array$instanceCount The instance count
* @param string $configuration XML configuration represented as a string
* @throws Microsoft_WindowsAzure_Management_Exception
$roleName = array($roleName);
$instanceCount = array($instanceCount);
$configuration = preg_replace('/(<\?xml[^?]+?)utf-16/i', '$1utf-8', $configuration);
//$configuration = '<?xml version="1.0">' . substr($configuration, strpos($configuration, '>') + 2);
// http://www.php.net/manual/en/simplexmlelement.xpath.php#97818
$namespaces = $xml->getDocNamespaces();
$xml->registerXPathNamespace('__empty_ns', $namespaces['']);
for ($i = 0; $i < count($roleName); $i++ ) {
$elements = $xml->xpath('//__empty_ns:Role[@name="' . $roleName[$i] . '"]/__empty_ns:Instances');
if (count($elements) == 1) {
$element['count'] = $instanceCount[$i];
$configuration = $xml->asXML();
//$configuration = preg_replace('/(<\?xml[^?]+?)utf-8/i', '$1utf-16', $configuration);
* The Change Deployment Configuration request may be specified as follows.
* Note that you can change a deployment's configuration either by specifying the deployment
* environment (staging or production), or by specifying the deployment's unique name.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $configuration XML configuration represented as a string
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($configuration == '' || is_null($configuration)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
* The Change Deployment Configuration request may be specified as follows.
* Note that you can change a deployment's configuration either by specifying the deployment
* environment (staging or production), or by specifying the deployment's unique name.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param string $configuration XML configuration represented as a string
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($configuration == '' || is_null($configuration)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
* The Change Deployment Configuration request may be specified as follows.
* Note that you can change a deployment's configuration either by specifying the deployment
* environment (staging or production), or by specifying the deployment's unique name.
* @param string $operationUrl The operation url
* @param string $configuration XML configuration represented as a string
* @throws Microsoft_WindowsAzure_Management_Exception
// Clean up the configuration
array('Content-Type' => 'application/xml; charset=utf-8'),
'<ChangeConfiguration xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Configuration>' . base64_encode($conformingConfiguration) . '</Configuration></ChangeConfiguration>');
if (!$response->isSuccessful()) {
* The Upgrade Deployment operation initiates an upgrade.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
* @param string $packageUrl The service configuration file for the deployment.
* @param string $configuration A label for this deployment, up to 100 characters in length.
* @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
* @param string $roleToUpgrade The name of the specific role to upgrade.
* @throws Microsoft_WindowsAzure_Management_Exception
public function upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $packageUrl, $configuration, $mode = 'auto', $roleToUpgrade = null)
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($label == '' || is_null($label)) {
if ($packageUrl == '' || is_null($packageUrl)) {
if ($configuration == '' || is_null($configuration)) {
if ($mode != 'auto' && $mode != 'manual') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
return $this->_upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade);
* The Upgrade Deployment operation initiates an upgrade.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
* @param string $packageUrl The service configuration file for the deployment.
* @param string $configuration A label for this deployment, up to 100 characters in length.
* @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
* @param string $roleToUpgrade The name of the specific role to upgrade.
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($label == '' || is_null($label)) {
if ($packageUrl == '' || is_null($packageUrl)) {
if ($configuration == '' || is_null($configuration)) {
if ($mode != 'auto' && $mode != 'manual') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
return $this->_upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade);
* The Upgrade Deployment operation initiates an upgrade.
* @param string $operationUrl The operation url
* @param string $label A URL that refers to the location of the service package in the Blob service. The service package must be located in a storage account beneath the same subscription.
* @param string $packageUrl The service configuration file for the deployment.
* @param string $configuration A label for this deployment, up to 100 characters in length.
* @param string $mode The type of upgrade to initiate. Possible values are Auto or Manual.
* @param string $roleToUpgrade The name of the specific role to upgrade.
* @throws Microsoft_WindowsAzure_Management_Exception
protected function _upgradeDeployment($operationUrl, $label, $packageUrl, $configuration, $mode, $roleToUpgrade)
// Clean up the configuration
array('Content-Type' => 'application/xml; charset=utf-8'),
'<UpgradeDeployment xmlns="http://schemas.microsoft.com/windowsazure"><Mode>' . ucfirst($mode) . '</Mode><PackageUrl>' . $packageUrl . '</PackageUrl><Configuration>' . base64_encode($conformingConfiguration) . '</Configuration><Label>' . base64_encode($label) . '</Label>' . (!is_null($roleToUpgrade) ? '<RoleToUpgrade>' . $roleToUpgrade . '</RoleToUpgrade>' : '') . '</UpgradeDeployment>');
if (!$response->isSuccessful()) {
* The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot;
* The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId;
* The Walk Upgrade Domain operation specifies the next upgrade domain to be walked during an in-place upgrade.
* @param string $operationUrl The operation url
* @param int $upgradeDomain An integer value that identifies the upgrade domain to walk. Upgrade domains are identified with a zero-based index: the first upgrade domain has an ID of 0, the second has an ID of 1, and so on.
* @throws Microsoft_WindowsAzure_Management_Exception
$response = $this->_performRequest($operationUrl . '/', '?comp=walkupgradedomain',
array('Content-Type' => 'application/xml; charset=utf-8'),
'<WalkUpgradeDomain xmlns="http://schemas.microsoft.com/windowsazure"><UpgradeDomain>' . $upgradeDomain . '</UpgradeDomain></WalkUpgradeDomain>');
if (!$response->isSuccessful()) {
* The Reboot Role Instance operation requests a reboot of a role instance
* that is running in a deployment.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $roleInstanceName The role instance name
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($roleInstanceName == '' || is_null($roleInstanceName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot . '/roleinstances/' . $roleInstanceName;
* The Reboot Role Instance operation requests a reboot of a role instance
* that is running in a deployment.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param string $roleInstanceName The role instance name
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($roleInstanceName == '' || is_null($roleInstanceName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId . '/roleinstances/' . $roleInstanceName;
* The Reimage Role Instance operation requests a reimage of a role instance
* that is running in a deployment.
* @param string $serviceName The service name
* @param string $deploymentSlot The deployment slot (production or staging)
* @param string $roleInstanceName The role instance name
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentSlot != 'production' && $deploymentSlot != 'staging') {
if ($roleInstanceName == '' || is_null($roleInstanceName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deploymentslots/' . $deploymentSlot . '/roleinstances/' . $roleInstanceName;
* The Reimage Role Instance operation requests a reimage of a role instance
* that is running in a deployment.
* @param string $serviceName The service name
* @param string $deploymentId The deployment ID as listed on the Windows Azure management portal
* @param string $roleInstanceName The role instance name
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if ($deploymentId == '' || is_null($deploymentId)) {
if ($roleInstanceName == '' || is_null($roleInstanceName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/deployments/' . $deploymentId . '/roleinstances/' . $roleInstanceName;
* Reboots or reimages a role instance.
* @param string $operationUrl The operation url
* @param string $operation The operation (reboot|reimage)
* @throws Microsoft_WindowsAzure_Management_Exception
if (!$response->isSuccessful()) {
* The List Certificates operation lists all certificates associated with
* the specified hosted service.
* @param string $serviceName The service name
* @return array Array of Microsoft_WindowsAzure_Management_CertificateInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates';
if ($response->isSuccessful()) {
if (!$result->Certificate) {
if (count($result->Certificate) > 1) {
$xmlServices = $result->Certificate;
$xmlServices = array($result->Certificate);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->CertificateUrl,
(string) $xmlServices[$i]->Thumbprint,
(string) $xmlServices[$i]->ThumbprintAlgorithm,
(string) $xmlServices[$i]->Data
* The Get Certificate operation returns the public data for the specified certificate.
* @param string $serviceName|$certificateUrl The service name -or- the certificate URL
* @param string $algorithm Algorithm
* @param string $thumbprint Thumbprint
* @return Microsoft_WindowsAzure_Management_CertificateInstance
* @throws Microsoft_WindowsAzure_Management_Exception
public function getCertificate($serviceName, $algorithm = '', $thumbprint = '')
if ($serviceName == '' || is_null($serviceName)) {
if (strpos($serviceName, 'https') === false && ($algorithm == '' || is_null($algorithm)) && ($thumbprint == '' || is_null($thumbprint))) {
if (strpos($serviceName, 'https') === false) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates/' . $algorithm . '-' . strtoupper($thumbprint);
if ($response->isSuccessful()) {
* The Add Certificate operation adds a certificate to the subscription.
* @param string $serviceName The service name
* @param string $certificateData Certificate data
* @param string $certificatePassword The certificate password
* @param string $certificateFormat The certificate format. Currently, only 'pfx' is supported.
* @throws Microsoft_WindowsAzure_Management_Exception
public function addCertificate($serviceName, $certificateData, $certificatePassword, $certificateFormat = 'pfx')
if ($serviceName == '' || is_null($serviceName)) {
if ($certificateData == '' || is_null($certificateData)) {
if ($certificatePassword == '' || is_null($certificatePassword)) {
if ($certificateFormat != 'pfx') {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates';
array('Content-Type' => 'application/xml; charset=utf-8'),
'<CertificateFile xmlns="http://schemas.microsoft.com/windowsazure"><Data>' . base64_encode($certificateData) . '</Data><CertificateFormat>' . $certificateFormat . '</CertificateFormat><Password>' . $certificatePassword . '</Password></CertificateFile>');
if (!$response->isSuccessful()) {
* The Delete Certificate operation deletes a certificate from the subscription's certificate store.
* @param string $serviceName|$certificateUrl The service name -or- the certificate URL
* @param string $algorithm Algorithm
* @param string $thumbprint Thumbprint
* @throws Microsoft_WindowsAzure_Management_Exception
if ($serviceName == '' || is_null($serviceName)) {
if (strpos($serviceName, 'https') === false && ($algorithm == '' || is_null($algorithm)) && ($thumbprint == '' || is_null($thumbprint))) {
if (strpos($serviceName, 'https') === false) {
$operationUrl = self::OP_HOSTED_SERVICES . '/' . $serviceName . '/certificates/' . $algorithm . '-' . strtoupper($thumbprint);
if (!$response->isSuccessful()) {
* The List Affinity Groups operation lists the affinity groups associated with
* the specified subscription.
* @return array Array of Microsoft_WindowsAzure_Management_AffinityGroupInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
if (!$result->AffinityGroup) {
if (count($result->AffinityGroup) > 1) {
$xmlServices = $result->AffinityGroup;
$xmlServices = array($result->AffinityGroup);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Name,
(string) $xmlServices[$i]->Label,
(string) $xmlServices[$i]->Description,
(string) $xmlServices[$i]->Location
* The Create Affinity Group operation creates a new affinity group for the specified subscription.
* @param string $name A name for the affinity group that is unique to the subscription.
* @param string $label A label for the affinity group. The label may be up to 100 characters in length.
* @param string $description A description for the affinity group. The description may be up to 1024 characters in length.
* @param string $location The location where the affinity group will be created. To list available locations, use the List Locations operation.
if ($name == '' || is_null($name)) {
if ($label == '' || is_null($label)) {
if (strlen($description) > 1024) {
if ($location == '' || is_null($location)) {
array('Content-Type' => 'application/xml; charset=utf-8'),
'<CreateAffinityGroup xmlns="http://schemas.microsoft.com/windowsazure"><Name>' . $name . '</Name><Label>' . base64_encode($label) . '</Label><Description>' . $description . '</Description><Location>' . $location . '</Location></CreateAffinityGroup>');
if (!$response->isSuccessful()) {
* The Update Affinity Group operation updates the label and/or the description for an affinity group for the specified subscription.
* @param string $name The name for the affinity group that should be updated.
* @param string $label A label for the affinity group. The label may be up to 100 characters in length.
* @param string $description A description for the affinity group. The description may be up to 1024 characters in length.
if ($name == '' || is_null($name)) {
if ($label == '' || is_null($label)) {
if (strlen($description) > 1024) {
$response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $name, '',
array('Content-Type' => 'application/xml; charset=utf-8'),
'<UpdateAffinityGroup xmlns="http://schemas.microsoft.com/windowsazure"><Label>' . base64_encode($label) . '</Label><Description>' . $description . '</Description></UpdateAffinityGroup>');
if (!$response->isSuccessful()) {
* The Delete Affinity Group operation deletes an affinity group in the specified subscription.
* @param string $name The name for the affinity group that should be deleted.
if ($name == '' || is_null($name)) {
$response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $name, '',
if (!$response->isSuccessful()) {
* The Get Affinity Group Properties operation returns the
* system properties associated with the specified affinity group.
* @param string $affinityGroupName The affinity group name.
* @return Microsoft_WindowsAzure_Management_AffinityGroupInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($affinityGroupName == '' || is_null($affinityGroupName)) {
$response = $this->_performRequest(self::OP_AFFINITYGROUPS . '/' . $affinityGroupName);
if ($response->isSuccessful()) {
(string) $result->Description,
(string) $result->Location
if (count($result->HostedServices->HostedService) > 1) {
$xmlService = $result->HostedServices->HostedService;
$xmlService = array($result->HostedServices->HostedService);
for ($i = 0; $i < count($xmlService); $i++ ) {
'url' => (string) $xmlService[$i]->Url,
'name' => (string) $xmlService[$i]->ServiceName
$affinityGroup->HostedServices = $services;
if (count($result->StorageServices->StorageService) > 1) {
$xmlService = $result->StorageServices->StorageService;
$xmlService = array($result->StorageServices->StorageService);
for ($i = 0; $i < count($xmlService); $i++ ) {
'url' => (string) $xmlService[$i]->Url,
'name' => (string) $xmlService[$i]->ServiceName
$affinityGroup->StorageServices = $services;
* The List Locations operation lists all of the data center locations
* that are valid for your subscription.
* @return array Array of Microsoft_WindowsAzure_Management_LocationInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
if (!$result->Location) {
if (count($result->Location) > 1) {
$xmlServices = $result->Location;
$xmlServices = array($result->Location);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Name
* The List Operating Systems operation lists the versions of the guest operating system
* that are currently available in Windows Azure. The 2010-10-28 version of List Operating
* Systems also indicates what family an operating system version belongs to.
* Currently Windows Azure supports two operating system families: the Windows Azure guest
* operating system that is substantially compatible with Windows Server 2008 SP2,
* and the Windows Azure guest operating system that is substantially compatible with
* Windows Server 2008 R2.
* @return array Array of Microsoft_WindowsAzure_Management_OperatingSystemInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
if (!$result->OperatingSystem) {
if (count($result->OperatingSystem) > 1) {
$xmlServices = $result->OperatingSystem;
$xmlServices = array($result->OperatingSystem);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Version,
(string) $xmlServices[$i]->Label,
((string) $xmlServices[$i]->IsDefault == 'true'),
((string) $xmlServices[$i]->IsActive == 'true'),
(string) $xmlServices[$i]->Family,
(string) $xmlServices[$i]->FamilyLabel
* The List OS Families operation lists the guest operating system families
* available in Windows Azure, and also lists the operating system versions
* available for each family. Currently Windows Azure supports two operating
* system families: the Windows Azure guest operating system that is
* substantially compatible with Windows Server 2008 SP2, and the Windows
* Azure guest operating system that is substantially compatible with
* Windows Server 2008 R2.
* @return array Array of Microsoft_WindowsAzure_Management_OperatingSystemFamilyInstance
* @throws Microsoft_WindowsAzure_Management_Exception
if ($response->isSuccessful()) {
if (!$result->OperatingSystemFamily) {
if (count($result->OperatingSystemFamily) > 1) {
$xmlServices = $result->OperatingSystemFamily;
$xmlServices = array($result->OperatingSystemFamily);
for ($i = 0; $i < count($xmlServices); $i++ ) {
(string) $xmlServices[$i]->Name,
(string) $xmlServices[$i]->Label
if (count($xmlServices[$i]->OperatingSystems->OperatingSystem) > 1) {
$xmlOperatingSystems = $xmlServices[$i]->OperatingSystems->OperatingSystem;
$xmlOperatingSystems = array($xmlServices[$i]->OperatingSystems->OperatingSystem);
$operatingSystems = array();
if (!is_null($xmlOperatingSystems)) {
for ($i = 0; $i < count($xmlOperatingSystems); $i++ ) {
(string) $xmlOperatingSystems[$i]->Version,
(string) $xmlOperatingSystems[$i]->Label,
((string) $xmlOperatingSystems[$i]->IsDefault == 'true'),
((string) $xmlOperatingSystems[$i]->IsActive == 'true'),
(string) $xmlServices[$i]->Name,
(string) $xmlServices[$i]->Label
$services[ count($services) - 1 ]->OperatingSystems = $operatingSystems;
* @param string $configuration Configuration to clean.
$configuration = str_replace('?<?', '<?', $configuration);
$configuration = str_replace("\r", "", $configuration);
$configuration = str_replace("\n", "", $configuration);
|