/** * Creates a deployment from a local package file and service configuration. * * @command-name CreateFromLocal * @command-description Creates a deployment from a local package file and service configuration. * @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. * @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. * @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. * @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. * @command-parameter-for $deploymentName Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment. * @command-parameter-for $label Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment. * @command-parameter-for $deploymentSlot Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --BySlot Required. The slot to deploy to. * @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. * @command-parameter-for $serviceConfigurationLocation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. * @command-parameter-for $storageAccount Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StorageAccount Required. Storage account to use when creating the deployment. * @command-parameter-for $startImmediately Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation. * @command-parameter-for $warningsAsErrors Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors. * @command-parameter-for $waitForOperation Microsoft_Console_Command_ParameterSource_Argv|Microsoft_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? * @command-example Create a deployment from a local .cspkg: * @command-example CreateFromLocal -sid="<your_subscription_id>" -cert="mycert.pem" --Name="hostedservicename" --DeploymentName="deploymentname" * @command-example --Label="deploymentlabel" --BySlot="production" --PackageLocation=".\service.cspkg" * @command-example --ServiceConfigLocation=".\ServiceConfiguration.cscfg" --StorageAccount="mystorage" * @command-example --StartImmediately --WaitFor */ public function createFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $deploymentSlot, $packageLocation, $serviceConfigurationLocation, $storageAccount, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false) { if (!is_null($deploymentSlot) && $deploymentSlot != '') { $deploymentSlot = strtolower($deploymentSlot); } if ($deploymentSlot != 'staging' && $deploymentSlot != 'production') { throw new Microsoft_Console_Exception('The deployment slot specified should be either staging|production.'); } $client = new Microsoft_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); $blobClient = $client->createBlobClientForService($storageAccount); $blobClient->createContainerIfNotExists('phpazuredeployments'); $blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation); $package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation)); $client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors); $client->waitForOperation(); $blobClient->deleteBlob('phpazuredeployments', basename($packageLocation)); if ($waitForOperation) { $client->waitForOperation(); } echo $client->getLastRequestId(); }