PageRenderTime 269ms CodeModel.GetById 121ms app.highlight 55ms RepoModel.GetById 85ms app.codeStats 1ms

/vendor/Microsoft/WindowsAzure/CommandLine/Deployment.php

https://bitbucket.org/ktos/tinyshare
PHP | 745 lines | 306 code | 85 blank | 354 comment | 91 complexity | 63c91d55dcf1f46b86f11c2133535832 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1<?php
  2/**
  3 * Copyright (c) 2009 - 2011, RealDolmen
  4 * All rights reserved.
  5 *
  6 * Redistribution and use in source and binary forms, with or without
  7 * modification, are permitted provided that the following conditions are met:
  8 *     * Redistributions of source code must retain the above copyright
  9 *       notice, this list of conditions and the following disclaimer.
 10 *     * Redistributions in binary form must reproduce the above copyright
 11 *       notice, this list of conditions and the following disclaimer in the
 12 *       documentation and/or other materials provided with the distribution.
 13 *     * Neither the name of RealDolmen nor the
 14 *       names of its contributors may be used to endorse or promote products
 15 *       derived from this software without specific prior written permission.
 16 *
 17 * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 20 * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 27 *
 28 * @category   Microsoft
 29 * @package    Microsoft_Console
 30 * @subpackage Exception
 31 * @version    $Id: Exception.php 55733 2011-01-03 09:17:16Z unknown $
 32 * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
 33 * @license    http://phpazure.codeplex.com/license
 34 */
 35
 36/**
 37 * @see Microsoft_AutoLoader
 38 */
 39require_once dirname(__FILE__) . '/../../AutoLoader.php';
 40
 41/**
 42 * Deployment commands
 43 * 
 44 * @category   Microsoft
 45 * @package    Microsoft_WindowsAzure_CommandLine
 46 * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
 47 * @license    http://phpazure.codeplex.com/license
 48 * 
 49 * @command-handler deployment
 50 * @command-handler-description Windows Azure Deployment commands
 51 * @command-handler-header Windows Azure SDK for PHP
 52 * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
 53 * @command-handler-footer Note: Parameters that are common across all commands can be stored 
 54 * @command-handler-footer in two dedicated environment variables.
 55 * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
 56 * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
 57 * @command-handler-footer 
 58 * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
 59 * @command-handler-footer The parameter file is a simple INI file carrying one parameter
 60 * @command-handler-footer value per line. It accepts the same parameters as one can
 61 * @command-handler-footer use from the command line command.
 62 */
 63class Microsoft_WindowsAzure_CommandLine_Deployment
 64	extends Microsoft_Console_Command
 65{	
 66	/**
 67	 * Creates a deployment from a remote package file and service configuration.
 68	 * 
 69	 * @command-name CreateFromStorage
 70	 * @command-description Creates a deployment from a remote package file and service configuration.
 71	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
 72	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
 73	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
 74	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Name Required. The hosted service DNS name to operate on.
 75	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment.
 76	 * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment.
 77	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required. The slot to deploy to.
 78	 * @command-parameter-for $packageUrl Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --PackageUrl Required. The remote location of the .cspkg file.
 79	 * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
 80	 * @command-parameter-for $startImmediately Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation.
 81	 * @command-parameter-for $warningsAsErrors Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors.
 82	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
 83	 * @command-example Create a deployment from a remote .cspkg:
 84	 * @command-example CreateFromStorage -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
 85	 * @command-example --Label="deploymentlabel" --BySlot="production"
 86	 * @command-example --PackageUrl="http://acct.blob.core.windows.net/pkgs/service.cspkg"
 87	 * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg" --StartImmediately --WaitFor
 88	 */
 89	public function createFromStorageCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $deploymentSlot, $packageUrl, $serviceConfigurationLocation, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false)
 90	{
 91		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 92			$deploymentSlot = strtolower($deploymentSlot);
 93		}
 94		if ($deploymentSlot != 'staging' && $deploymentSlot != 'production') {
 95			throw new Microsoft_Console_Exception('The deployment slot specified should be either staging|production.');
 96		}
 97
 98		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 99		$client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors);
100
101		if ($waitForOperation) {
102			$client->waitForOperation();
103		}
104		echo $client->getLastRequestId();
105	}
106	
107	/**
108	 * Creates a deployment from a local package file and service configuration.
109	 * 
110	 * @command-name CreateFromLocal
111	 * @command-description Creates a deployment from a local package file and service configuration.
112	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
113	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
114	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
115	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Name Required. The hosted service DNS name to operate on.
116	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment.
117	 * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment.
118	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required. The slot to deploy to.
119	 * @command-parameter-for $packageLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_StdIn --PackageLocation Required. The location of the .cspkg file.
120	 * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
121	 * @command-parameter-for $storageAccount Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StorageAccount Required. Storage account to use when creating the deployment.
122	 * @command-parameter-for $startImmediately Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation.
123	 * @command-parameter-for $warningsAsErrors Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors.
124	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
125	 * @command-example Create a deployment from a local .cspkg:
126	 * @command-example CreateFromLocal -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
127	 * @command-example --Label="deploymentlabel" --BySlot="production" --PackageLocation=".\service.cspkg"
128	 * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg" --StorageAccount="mystorage"
129	 * @command-example --StartImmediately --WaitFor
130	 */
131	public function createFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $deploymentSlot, $packageLocation, $serviceConfigurationLocation, $storageAccount, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false)
132	{
133		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
134			$deploymentSlot = strtolower($deploymentSlot);
135		}
136		if ($deploymentSlot != 'staging' && $deploymentSlot != 'production') {
137			throw new Microsoft_Console_Exception('The deployment slot specified should be either staging|production.');
138		}
139
140		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
141		$blobClient = $client->createBlobClientForService($storageAccount);
142		$blobClient->createContainerIfNotExists('phpazuredeployments');
143		$blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation);
144		$package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation));
145		
146		$client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors);
147
148		$client->waitForOperation();
149		$blobClient->deleteBlob('phpazuredeployments', basename($packageLocation));
150		
151		if ($waitForOperation) {
152			$client->waitForOperation();
153		}
154		echo $client->getLastRequestId();
155	}
156	
157	/**
158	 * Get deployment properties.
159	 * 
160	 * @command-name GetProperties
161	 * @command-description Get deployment properties.
162	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
163	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
164	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
165	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
166	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
167	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
168	 * @command-example Get deployment properties for service "phptest" (production slot):
169	 * @command-example GetProperties -sid="<your_subscription_id>" -cert="mycert.pem" --Name="servicename" --BySlot="production"
170	 */
171	public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName)
172	{
173		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
174		
175		$result = null;
176		
177		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
178			$deploymentSlot = strtolower($deploymentSlot);
179			
180			$result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
181		} else {
182			$result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
183		}
184
185		$this->_displayObjectInformation($result, array('Name', 'DeploymentSlot', 'Label', 'Url', 'Status')); 
186	}
187	
188	/**
189	 * Get hosted service account property.
190	 * 
191	 * @command-name GetProperty
192	 * @command-description Get deployment property.
193	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
194	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
195	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
196	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
197	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
198	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
199	 * @command-parameter-for $property Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Property|-prop Required. The property to retrieve for the hosted service account.
200	 * @command-example Get deployment property "Name" for service "phptest" (production slot):
201	 * @command-example GetProperties -sid="<your_subscription_id>" -cert="mycert.pem"
202	 * @command-example --Name="servicename" --BySlot="production" --Property="Name"
203	 */
204	public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $property)
205	{
206		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
207		
208		$result = null;
209		
210		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
211			$deploymentSlot = strtolower($deploymentSlot);
212			
213			$result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
214		} else {
215			$result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
216		}
217		
218		printf("%s\r\n", $result->$property);
219	}
220	
221	/**
222	 * Get role instances.
223	 * 
224	 * @command-name GetRoleInstances
225	 * @command-description Get role instance information (instance count, instance names, and instance statuses for a specified deployment.
226	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
227	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
228	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
229	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
230	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
231	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
232	 * @command-example Get role instances for production-slot deployment of the hosted service "phptest":
233	 * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
234	 * @command-example --Name="servicename" --BySlot="production"
235	 */
236	public function getRoleInstances($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName)
237	{
238		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
239		
240		$result = null;
241		
242		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
243			$deploymentSlot = strtolower($deploymentSlot);
244			
245			$result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
246		} else {
247			$result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
248		}
249		
250		printf("InstanceCount:%s\n\n", count($result));
251		$instance_index = 0;
252		foreach($result as $instance) {
253			printf("Instance%s\n", $instance_index );
254			printf("Name:%s\n", $instance['instancename']);
255			printf("Status:%s\n", $instance['instancestatus']);
256			printf("\n");
257			$instance_index++;
258		}
259	}
260	
261	/**
262	 * Get role instance properties.
263	 * 
264	 * @command-name GetRoleInstanceProperties
265	 * @command-description Get role instance information for a specified role instance.
266	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
267	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
268	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
269	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
270	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
271	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
272	 * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --InstanceName Required. The role instance name to retrieve properties for.
273	 * @command-example Get role instance properties for role "role_0" for production-slot deployment of the hosted service "phptest":
274	 * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
275	 * @command-example --Name="servicename" --BySlot="production" --InstanceName="role_0"
276	 */
277	public function getRoleInstanceProperties($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName)
278	{
279		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
280		
281		$result = null;
282		
283		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
284			$deploymentSlot = strtolower($deploymentSlot);
285			
286			$result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
287		} else {
288			$result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
289		}
290		
291		$instance_found = false;
292		
293		foreach($result as $instance) {
294			if($instance['instancename'] == $instanceName) {
295				printf("Status: \t%s\n", $instance['instancestatus']);
296				printf("Upgrade domain: %s\n", $instance['instanceupgradedomain']);
297				printf("Fault domain: \t%s\n", $instance['instancefaultdomain']);
298				printf("Size: \t\t%s\n", $instance['instancesize']);
299				printf("\n");
300				$instance_found = true;
301				continue;
302			}
303		}
304		
305		if(!$instance_found) {
306				printf("No instance with name %s was found.", $instanceName);
307		}
308	}
309	
310	/**
311	 * Get a role instance property.
312	 * 
313	 * @command-name GetRoleInstanceProperty
314	 * @command-description Get a specified role instance property for a specified role instance.
315	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
316	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
317	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
318	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
319	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
320	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
321	 * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --InstanceName Required. The role instance name to retrieve properties for.
322	 * @command-parameter-for $propertyName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --PropertyName Required. The role instance property to retrieve.
323	 * @command-example Get role instance property "Status" for role "role_0" for production-slot deployment of the hosted service "phptest":
324	 * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
325	 * @command-example --Name="servicename" --BySlot="production" --InstanceName="role_0" --PropertyName="Status"
326	 * @command-example Possible values for PropertyName are "Role Name", "Status", "Upgrade Domain", "Fault Domain", "Size"
327	 */
328	public function getRoleInstanceProperty($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $propertyName)
329	{
330		if (!in_array($propertyName, array("Role Name", "Status", "Upgrade Domain", "Fault Domain", "Size"))) {
331			printf("%s is not a valid property name. Valid property names are 'Role Name', 'Status', 'Upgrade Domain', 'Fault Domain', 'Size'", $propertyName);
332			return;
333		}
334		
335		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
336		
337		$result = null;
338		
339		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
340			$deploymentSlot = strtolower($deploymentSlot);
341			
342			$result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
343		} else {
344			$result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
345		}
346		
347		$instance_found = false;
348		
349		foreach($result as $instance) {
350			if($instance['instancename'] == $instanceName) {
351				switch($propertyName) {
352					case "Role Name":
353						printf($instance['rolename']);
354						break;
355					case "Status":
356						printf($instance['instancestatus']);
357						break;
358					case "Upgrade Domain":
359						printf($instance['instanceupgradedomain']);
360						break;
361					case "Fault Domain":
362						printf($instance['instancefaultdomain']);
363						break;
364					case "Size":
365						printf($instance['instancesize']);
366						break;
367				}
368				
369				$instance_found = true;
370				continue;
371			}
372		}
373		
374		if(!$instance_found) {
375			printf("No instance with name %s was found.", $instanceName);
376		}
377	}
378	
379	/**
380	 * Swap deployment slots (perform VIP swap).
381	 * 
382	 * @command-name Swap
383	 * @command-description Swap deployment slots (perform VIP swap).
384	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
385	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
386	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
387	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
388	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
389	 * @command-example Swap deployment slots:
390	 * @command-example Swap -sid="<your_subscription_id>" -cert="mycert.pem" --Name="servicename"
391	 */
392	public function swapCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $waitForOperation = false)
393	{
394		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
395		
396		$productionDeploymentName = null;
397		try { $productionDeploymentName = $client->getDeploymentBySlot($serviceName, 'production')->Name; } catch (Exception $ex) {}
398		
399		$stagingDeploymentName = null;
400		try { $stagingDeploymentName = $client->getDeploymentBySlot($serviceName, 'staging')->Name; } catch (Exception $ex) {}
401		
402		if (is_null($productionDeploymentName)) {
403			$productionDeploymentName = $stagingDeploymentName;
404		}
405		if (is_null($stagingDeploymentName)) {
406			throw new Microsoft_Console_Exception('Swapping deployment slots is only possible when both slots have an active deployment or when production slot is empty.');
407		}
408
409		$client->swapDeployment($serviceName, $productionDeploymentName, $stagingDeploymentName);
410		
411		if ($waitForOperation) {
412			$client->waitForOperation();
413		}
414		echo $client->getLastRequestId();
415	}
416	
417	/**
418	 * Deletes a deployment.
419	 * 
420	 * @command-name Delete
421	 * @command-description Deletes a deployment.
422	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
423	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
424	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
425	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
426	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
427	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
428	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
429	 * @command-example Delete a deployment:
430	 * @command-example Delete -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
431	 */
432	public function deleteCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $waitForOperation = false)
433	{
434		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
435
436		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
437			$deploymentSlot = strtolower($deploymentSlot);
438			
439			$client->deleteDeploymentBySlot($serviceName, $deploymentSlot);
440		} else {
441			$client->deleteDeploymentByDeploymentId($serviceName, $deploymentName);
442		}
443		
444		if ($waitForOperation) {
445			$client->waitForOperation();
446		}
447		echo $client->getLastRequestId();
448	}
449	
450	/**
451	 * Updates a deployment's configuration.
452	 * 
453	 * @command-name UpdateConfig
454	 * @command-description Updates a deployment's configuration.
455	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
456	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
457	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
458	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
459	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
460	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
461	 * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
462	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
463	 * @command-example Update configuration:
464	 * @command-example UpdateConfig -sid="<your_subscription_id>" -cert="mycert.pem"
465	 * @command-example --Name="hostedservicename" --ByName="deploymentname"
466	 * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg"
467	 */
468	public function updateConfigurationCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $serviceConfigurationLocation, $waitForOperation = false)
469	{
470		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
471
472		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
473			$deploymentSlot = strtolower($deploymentSlot);
474			
475			$client->configureDeploymentBySlot($serviceName, $deploymentSlot, $serviceConfigurationLocation);
476		} else {
477			$client->configureDeploymentByDeploymentId($serviceName, $deploymentName, $serviceConfigurationLocation);
478		}
479		
480		if ($waitForOperation) {
481			$client->waitForOperation();
482		}
483		echo $client->getLastRequestId();
484	}
485	
486	/**
487	 * Updates a deployment's status.
488	 * 
489	 * @command-name UpdateStatus
490	 * @command-description Updates a deployment's status.
491	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
492	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
493	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
494	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
495	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
496	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
497	 * @command-parameter-for $newStatus Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Status Required. New status (Suspended|Running)
498	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
499	 * @command-example Suspend a deployment:
500	 * @command-example UpdateStatus -sid="<your_subscription_id>" -cert="mycert.pem"
501	 * @command-example --Name="hostedservicename" --ByName="deploymentname"
502	 * @command-example --Status="Suspended"
503	 */
504	public function updateStatusCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $newStatus, $waitForOperation = false)
505	{
506		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
507
508		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
509			$deploymentSlot = strtolower($deploymentSlot);
510			
511			$client->updateDeploymentStatusBySlot($serviceName, $deploymentSlot, $newStatus);
512		} else {
513			$client->updateDeploymentStatusByDeploymentId($serviceName, $deploymentName, $newStatus);
514		}
515		
516		if ($waitForOperation) {
517			$client->waitForOperation();
518		}
519		echo $client->getLastRequestId();
520	}
521	
522	/**
523	 * Updates the number of instances.
524	 * 
525	 * @command-name EditInstanceNumber
526	 * @command-description Updates the number of instances.
527	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
528	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
529	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
530	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
531	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
532	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
533	 * @command-parameter-for $roleName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --RoleName|-r Required. Role name to update the number of instances for.
534	 * @command-parameter-for $newInstanceNumber Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --NewInstanceNumber|-i Required. New number of instances.
535	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
536	 * @command-example Suspend a deployment:
537	 * @command-example EditInstanceNumber -sid="<your_subscription_id>" -cert="mycert.pem"
538	 * @command-example --Name="hostedservicename" --ByName="deploymentname"
539	 * @command-example --NewInstanceNumber="4"
540	 */
541	public function editInstanceNumberCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $roleName, $newInstanceNumber = 1, $waitForOperation = false)
542	{
543		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
544
545		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
546			$deploymentSlot = strtolower($deploymentSlot);
547			
548			$client->setInstanceCountBySlot($serviceName, $deploymentSlot, $roleName, $newInstanceNumber);
549		} else {
550			$client->setInstanceCountByDeploymentId($serviceName, $deploymentName, $roleName, $newInstanceNumber);
551		}
552		
553		if ($waitForOperation) {
554			$client->waitForOperation();
555		}
556		echo $client->getLastRequestId();
557	}
558	
559	/**
560	 * Reboots a role instance.
561	 * 
562	 * @command-name RebootInstance
563	 * @command-description Reboots a role instance.
564	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
565	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
566	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
567	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
568	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
569	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
570	 * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --RoleInstanceName Required. The name of the role instance to work with.
571	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
572	 * @command-example Reboot a role instance:
573	 * @command-example RebootInstance -sid="<your_subscription_id>" -cert="mycert.pem"
574	 * @command-example --Name="hostedservicename" --ByName="deploymentname"
575	 * @command-example --RoleInstanceName="PhpOnAzure.Web_IN_0"
576	 */
577	public function rebootInstanceCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $waitForOperation = false)
578	{
579		$client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
580
581		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
582			$deploymentSlot = strtolower($deploymentSlot);
583			
584			$client->rebootRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName);
585		} else {
586			$client->rebootRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName);
587		}
588		
589		if ($waitForOperation) {
590			$client->waitForOperation();
591		}
592		echo $client->getLastRequestId();
593	}
594	
595	/**
596	 * Reimages a role instance.
597	 * 
598	 * @command-name ReimageInstance
599	 * @command-description Reimages a role instance.
600	 * @command-parameter-for $subscriptionId Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
601	 * @command-parameter-for $certificate Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate.
602	 * @command-parameter-for $certificatePassphrase Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Passphrase|-p The certificate passphrase. If not specified, a prompt will be displayed.
603	 * @command-parameter-for $serviceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile|Microsoft_Console_Command_ParameterSource_Env|Microsoft_Console_Command_ParameterSource_StdIn --Name Required. The hosted service DNS name to operate on.
604	 * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for.
605	 * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for.
606	 * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --RoleInstanceName Required. The name of the role instance to work with.
607	 * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSou…

Large files files are truncated, but you can click here to view the full file