PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): BSD-3-Clause

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. * @see Microsoft_AutoLoader
  37. */
  38. require_once dirname(__FILE__) . '/../../AutoLoader.php';
  39. /**
  40. * Deployment commands
  41. *
  42. * @category Microsoft
  43. * @package Microsoft_WindowsAzure_CommandLine
  44. * @copyright Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  45. * @license http://phpazure.codeplex.com/license
  46. *
  47. * @command-handler deployment
  48. * @command-handler-description Windows Azure Deployment commands
  49. * @command-handler-header Windows Azure SDK for PHP
  50. * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
  51. * @command-handler-footer Note: Parameters that are common across all commands can be stored
  52. * @command-handler-footer in two dedicated environment variables.
  53. * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  54. * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
  55. * @command-handler-footer
  56. * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  57. * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  58. * @command-handler-footer value per line. It accepts the same parameters as one can
  59. * @command-handler-footer use from the command line command.
  60. */
  61. class Microsoft_WindowsAzure_CommandLine_Deployment
  62. extends Microsoft_Console_Command
  63. {
  64. /**
  65. * Creates a deployment from a remote package file and service configuration.
  66. *
  67. * @command-name CreateFromStorage
  68. * @command-description Creates a deployment from a remote package file and service configuration.
  69. * @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.
  70. * @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.
  71. * @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.
  72. * @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.
  73. * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment.
  74. * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment.
  75. * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required. The slot to deploy to.
  76. * @command-parameter-for $packageUrl Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --PackageUrl Required. The remote location of the .cspkg file.
  77. * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
  78. * @command-parameter-for $startImmediately Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation.
  79. * @command-parameter-for $warningsAsErrors Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors.
  80. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  81. * @command-example Create a deployment from a remote .cspkg:
  82. * @command-example CreateFromStorage -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
  83. * @command-example --Label="deploymentlabel" --BySlot="production"
  84. * @command-example --PackageUrl="http://acct.blob.core.windows.net/pkgs/service.cspkg"
  85. * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg" --StartImmediately --WaitFor
  86. */
  87. public function createFromStorageCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $deploymentSlot, $packageUrl, $serviceConfigurationLocation, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false)
  88. {
  89. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  90. $deploymentSlot = strtolower($deploymentSlot);
  91. }
  92. if ($deploymentSlot != 'staging' && $deploymentSlot != 'production') {
  93. throw new Microsoft_Console_Exception('The deployment slot specified should be either staging|production.');
  94. }
  95. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  96. $client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors);
  97. if ($waitForOperation) {
  98. $client->waitForOperation();
  99. }
  100. echo $client->getLastRequestId();
  101. }
  102. /**
  103. * Creates a deployment from a local package file and service configuration.
  104. *
  105. * @command-name CreateFromLocal
  106. * @command-description Creates a deployment from a local package file and service configuration.
  107. * @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.
  108. * @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.
  109. * @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.
  110. * @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.
  111. * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment.
  112. * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment.
  113. * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required. The slot to deploy to.
  114. * @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.
  115. * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
  116. * @command-parameter-for $storageAccount Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StorageAccount Required. Storage account to use when creating the deployment.
  117. * @command-parameter-for $startImmediately Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation.
  118. * @command-parameter-for $warningsAsErrors Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors.
  119. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  120. * @command-example Create a deployment from a local .cspkg:
  121. * @command-example CreateFromLocal -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
  122. * @command-example --Label="deploymentlabel" --BySlot="production" --PackageLocation=".\service.cspkg"
  123. * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg" --StorageAccount="mystorage"
  124. * @command-example --StartImmediately --WaitFor
  125. */
  126. public function createFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $deploymentSlot, $packageLocation, $serviceConfigurationLocation, $storageAccount, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false)
  127. {
  128. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  129. $deploymentSlot = strtolower($deploymentSlot);
  130. }
  131. if ($deploymentSlot != 'staging' && $deploymentSlot != 'production') {
  132. throw new Microsoft_Console_Exception('The deployment slot specified should be either staging|production.');
  133. }
  134. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  135. $blobClient = $client->createBlobClientForService($storageAccount);
  136. $blobClient->createContainerIfNotExists('phpazuredeployments');
  137. $blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation);
  138. $package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation));
  139. $client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors);
  140. $client->waitForOperation();
  141. $blobClient->deleteBlob('phpazuredeployments', basename($packageLocation));
  142. if ($waitForOperation) {
  143. $client->waitForOperation();
  144. }
  145. echo $client->getLastRequestId();
  146. }
  147. /**
  148. * Get deployment properties.
  149. *
  150. * @command-name GetProperties
  151. * @command-description Get deployment properties.
  152. * @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.
  153. * @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.
  154. * @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.
  155. * @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.
  156. * @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.
  157. * @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.
  158. * @command-example Get deployment properties for service "phptest" (production slot):
  159. * @command-example GetProperties -sid="<your_subscription_id>" -cert="mycert.pem" --Name="servicename" --BySlot="production"
  160. */
  161. public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName)
  162. {
  163. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  164. $result = null;
  165. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  166. $deploymentSlot = strtolower($deploymentSlot);
  167. $result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
  168. } else {
  169. $result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
  170. }
  171. $this->_displayObjectInformation($result, array('Name', 'DeploymentSlot', 'Label', 'Url', 'Status'));
  172. }
  173. /**
  174. * Get hosted service account property.
  175. *
  176. * @command-name GetProperty
  177. * @command-description Get deployment property.
  178. * @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.
  179. * @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.
  180. * @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.
  181. * @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.
  182. * @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.
  183. * @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.
  184. * @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.
  185. * @command-example Get deployment property "Name" for service "phptest" (production slot):
  186. * @command-example GetProperties -sid="<your_subscription_id>" -cert="mycert.pem"
  187. * @command-example --Name="servicename" --BySlot="production" --Property="Name"
  188. */
  189. public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $property)
  190. {
  191. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  192. $result = null;
  193. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  194. $deploymentSlot = strtolower($deploymentSlot);
  195. $result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
  196. } else {
  197. $result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
  198. }
  199. printf("%s\r\n", $result->$property);
  200. }
  201. /**
  202. * Get role instances.
  203. *
  204. * @command-name GetRoleInstances
  205. * @command-description Get role instance information (instance count, instance names, and instance statuses for a specified deployment.
  206. * @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.
  207. * @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.
  208. * @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.
  209. * @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.
  210. * @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.
  211. * @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.
  212. * @command-example Get role instances for production-slot deployment of the hosted service "phptest":
  213. * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
  214. * @command-example --Name="servicename" --BySlot="production"
  215. */
  216. public function getRoleInstances($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName)
  217. {
  218. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  219. $result = null;
  220. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  221. $deploymentSlot = strtolower($deploymentSlot);
  222. $result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
  223. } else {
  224. $result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
  225. }
  226. printf("InstanceCount:%s\n\n", count($result));
  227. $instance_index = 0;
  228. foreach($result as $instance) {
  229. printf("Instance%s\n", $instance_index );
  230. printf("Name:%s\n", $instance['instancename']);
  231. printf("Status:%s\n", $instance['instancestatus']);
  232. printf("\n");
  233. $instance_index++;
  234. }
  235. }
  236. /**
  237. * Get role instance properties.
  238. *
  239. * @command-name GetRoleInstanceProperties
  240. * @command-description Get role instance information for a specified role instance.
  241. * @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.
  242. * @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.
  243. * @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.
  244. * @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.
  245. * @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.
  246. * @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.
  247. * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --InstanceName Required. The role instance name to retrieve properties for.
  248. * @command-example Get role instance properties for role "role_0" for production-slot deployment of the hosted service "phptest":
  249. * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
  250. * @command-example --Name="servicename" --BySlot="production" --InstanceName="role_0"
  251. */
  252. public function getRoleInstanceProperties($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName)
  253. {
  254. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  255. $result = null;
  256. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  257. $deploymentSlot = strtolower($deploymentSlot);
  258. $result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
  259. } else {
  260. $result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
  261. }
  262. $instance_found = false;
  263. foreach($result as $instance) {
  264. if($instance['instancename'] == $instanceName) {
  265. printf("Status: \t%s\n", $instance['instancestatus']);
  266. printf("Upgrade domain: %s\n", $instance['instanceupgradedomain']);
  267. printf("Fault domain: \t%s\n", $instance['instancefaultdomain']);
  268. printf("Size: \t\t%s\n", $instance['instancesize']);
  269. printf("\n");
  270. $instance_found = true;
  271. continue;
  272. }
  273. }
  274. if(!$instance_found) {
  275. printf("No instance with name %s was found.", $instanceName);
  276. }
  277. }
  278. /**
  279. * Get a role instance property.
  280. *
  281. * @command-name GetRoleInstanceProperty
  282. * @command-description Get a specified role instance property for a specified role instance.
  283. * @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.
  284. * @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.
  285. * @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.
  286. * @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.
  287. * @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.
  288. * @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.
  289. * @command-parameter-for $instanceName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --InstanceName Required. The role instance name to retrieve properties for.
  290. * @command-parameter-for $propertyName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --PropertyName Required. The role instance property to retrieve.
  291. * @command-example Get role instance property "Status" for role "role_0" for production-slot deployment of the hosted service "phptest":
  292. * @command-example GetRoleInstances -sid="<your_subscription_id>" -cert="mycert.pem"
  293. * @command-example --Name="servicename" --BySlot="production" --InstanceName="role_0" --PropertyName="Status"
  294. * @command-example Possible values for PropertyName are "Role Name", "Status", "Upgrade Domain", "Fault Domain", "Size"
  295. */
  296. public function getRoleInstanceProperty($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $propertyName)
  297. {
  298. if (!in_array($propertyName, array("Role Name", "Status", "Upgrade Domain", "Fault Domain", "Size"))) {
  299. printf("%s is not a valid property name. Valid property names are 'Role Name', 'Status', 'Upgrade Domain', 'Fault Domain', 'Size'", $propertyName);
  300. return;
  301. }
  302. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  303. $result = null;
  304. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  305. $deploymentSlot = strtolower($deploymentSlot);
  306. $result = $client->getRoleInstancesByDeploymentSlot($serviceName, $deploymentSlot);
  307. } else {
  308. $result = $client->getRoleInstancesByDeploymentId($serviceName, $deploymentName);
  309. }
  310. $instance_found = false;
  311. foreach($result as $instance) {
  312. if($instance['instancename'] == $instanceName) {
  313. switch($propertyName) {
  314. case "Role Name":
  315. printf($instance['rolename']);
  316. break;
  317. case "Status":
  318. printf($instance['instancestatus']);
  319. break;
  320. case "Upgrade Domain":
  321. printf($instance['instanceupgradedomain']);
  322. break;
  323. case "Fault Domain":
  324. printf($instance['instancefaultdomain']);
  325. break;
  326. case "Size":
  327. printf($instance['instancesize']);
  328. break;
  329. }
  330. $instance_found = true;
  331. continue;
  332. }
  333. }
  334. if(!$instance_found) {
  335. printf("No instance with name %s was found.", $instanceName);
  336. }
  337. }
  338. /**
  339. * Swap deployment slots (perform VIP swap).
  340. *
  341. * @command-name Swap
  342. * @command-description Swap deployment slots (perform VIP swap).
  343. * @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.
  344. * @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.
  345. * @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.
  346. * @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.
  347. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  348. * @command-example Swap deployment slots:
  349. * @command-example Swap -sid="<your_subscription_id>" -cert="mycert.pem" --Name="servicename"
  350. */
  351. public function swapCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $waitForOperation = false)
  352. {
  353. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  354. $productionDeploymentName = null;
  355. try { $productionDeploymentName = $client->getDeploymentBySlot($serviceName, 'production')->Name; } catch (Exception $ex) {}
  356. $stagingDeploymentName = null;
  357. try { $stagingDeploymentName = $client->getDeploymentBySlot($serviceName, 'staging')->Name; } catch (Exception $ex) {}
  358. if (is_null($productionDeploymentName)) {
  359. $productionDeploymentName = $stagingDeploymentName;
  360. }
  361. if (is_null($stagingDeploymentName)) {
  362. throw new Microsoft_Console_Exception('Swapping deployment slots is only possible when both slots have an active deployment or when production slot is empty.');
  363. }
  364. $client->swapDeployment($serviceName, $productionDeploymentName, $stagingDeploymentName);
  365. if ($waitForOperation) {
  366. $client->waitForOperation();
  367. }
  368. echo $client->getLastRequestId();
  369. }
  370. /**
  371. * Deletes a deployment.
  372. *
  373. * @command-name Delete
  374. * @command-description Deletes a deployment.
  375. * @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.
  376. * @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.
  377. * @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.
  378. * @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.
  379. * @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.
  380. * @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.
  381. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  382. * @command-example Delete a deployment:
  383. * @command-example Delete -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname"
  384. */
  385. public function deleteCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $waitForOperation = false)
  386. {
  387. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  388. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  389. $deploymentSlot = strtolower($deploymentSlot);
  390. $client->deleteDeploymentBySlot($serviceName, $deploymentSlot);
  391. } else {
  392. $client->deleteDeploymentByDeploymentId($serviceName, $deploymentName);
  393. }
  394. if ($waitForOperation) {
  395. $client->waitForOperation();
  396. }
  397. echo $client->getLastRequestId();
  398. }
  399. /**
  400. * Updates a deployment's configuration.
  401. *
  402. * @command-name UpdateConfig
  403. * @command-description Updates a deployment's configuration.
  404. * @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.
  405. * @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.
  406. * @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.
  407. * @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.
  408. * @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.
  409. * @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.
  410. * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file.
  411. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  412. * @command-example Update configuration:
  413. * @command-example UpdateConfig -sid="<your_subscription_id>" -cert="mycert.pem"
  414. * @command-example --Name="hostedservicename" --ByName="deploymentname"
  415. * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg"
  416. */
  417. public function updateConfigurationCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $serviceConfigurationLocation, $waitForOperation = false)
  418. {
  419. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  420. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  421. $deploymentSlot = strtolower($deploymentSlot);
  422. $client->configureDeploymentBySlot($serviceName, $deploymentSlot, $serviceConfigurationLocation);
  423. } else {
  424. $client->configureDeploymentByDeploymentId($serviceName, $deploymentName, $serviceConfigurationLocation);
  425. }
  426. if ($waitForOperation) {
  427. $client->waitForOperation();
  428. }
  429. echo $client->getLastRequestId();
  430. }
  431. /**
  432. * Updates a deployment's status.
  433. *
  434. * @command-name UpdateStatus
  435. * @command-description Updates a deployment's status.
  436. * @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.
  437. * @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.
  438. * @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.
  439. * @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.
  440. * @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.
  441. * @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.
  442. * @command-parameter-for $newStatus Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Status Required. New status (Suspended|Running)
  443. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  444. * @command-example Suspend a deployment:
  445. * @command-example UpdateStatus -sid="<your_subscription_id>" -cert="mycert.pem"
  446. * @command-example --Name="hostedservicename" --ByName="deploymentname"
  447. * @command-example --Status="Suspended"
  448. */
  449. public function updateStatusCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $newStatus, $waitForOperation = false)
  450. {
  451. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  452. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  453. $deploymentSlot = strtolower($deploymentSlot);
  454. $client->updateDeploymentStatusBySlot($serviceName, $deploymentSlot, $newStatus);
  455. } else {
  456. $client->updateDeploymentStatusByDeploymentId($serviceName, $deploymentName, $newStatus);
  457. }
  458. if ($waitForOperation) {
  459. $client->waitForOperation();
  460. }
  461. echo $client->getLastRequestId();
  462. }
  463. /**
  464. * Updates the number of instances.
  465. *
  466. * @command-name EditInstanceNumber
  467. * @command-description Updates the number of instances.
  468. * @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.
  469. * @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.
  470. * @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.
  471. * @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.
  472. * @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.
  473. * @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.
  474. * @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.
  475. * @command-parameter-for $newInstanceNumber Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --NewInstanceNumber|-i Required. New number of instances.
  476. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  477. * @command-example Suspend a deployment:
  478. * @command-example EditInstanceNumber -sid="<your_subscription_id>" -cert="mycert.pem"
  479. * @command-example --Name="hostedservicename" --ByName="deploymentname"
  480. * @command-example --NewInstanceNumber="4"
  481. */
  482. public function editInstanceNumberCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $roleName, $newInstanceNumber = 1, $waitForOperation = false)
  483. {
  484. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  485. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  486. $deploymentSlot = strtolower($deploymentSlot);
  487. $client->setInstanceCountBySlot($serviceName, $deploymentSlot, $roleName, $newInstanceNumber);
  488. } else {
  489. $client->setInstanceCountByDeploymentId($serviceName, $deploymentName, $roleName, $newInstanceNumber);
  490. }
  491. if ($waitForOperation) {
  492. $client->waitForOperation();
  493. }
  494. echo $client->getLastRequestId();
  495. }
  496. /**
  497. * Reboots a role instance.
  498. *
  499. * @command-name RebootInstance
  500. * @command-description Reboots a role instance.
  501. * @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.
  502. * @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.
  503. * @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.
  504. * @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.
  505. * @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.
  506. * @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.
  507. * @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.
  508. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
  509. * @command-example Reboot a role instance:
  510. * @command-example RebootInstance -sid="<your_subscription_id>" -cert="mycert.pem"
  511. * @command-example --Name="hostedservicename" --ByName="deploymentname"
  512. * @command-example --RoleInstanceName="PhpOnAzure.Web_IN_0"
  513. */
  514. public function rebootInstanceCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $waitForOperation = false)
  515. {
  516. $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
  517. if (!is_null($deploymentSlot) && $deploymentSlot != '') {
  518. $deploymentSlot = strtolower($deploymentSlot);
  519. $client->rebootRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName);
  520. } else {
  521. $client->rebootRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName);
  522. }
  523. if ($waitForOperation) {
  524. $client->waitForOperation();
  525. }
  526. echo $client->getLastRequestId();
  527. }
  528. /**
  529. * Reimages a role instance.
  530. *
  531. * @command-name ReimageInstance
  532. * @command-description Reimages a role instance.
  533. * @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.
  534. * @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.
  535. * @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.
  536. * @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.
  537. * @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.
  538. * @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.
  539. * @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.
  540. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSou…

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