/** * Sets the deployment slot. * * @param string $slot The deployment slot name. * * @return none */ public function setSlot($slot) { Validate::isString($slot, 'slot'); Validate::notNullOrEmpty($slot, 'slot'); Validate::isTrue(DeploymentSlot::isValid($slot), sprintf(Resources::INVALID_SLOT, $slot)); $this->_slot = $slot; }
/** * @covers WindowsAzure\ServiceManagement\Models\DeploymentSlot::isValid */ public function testIsValidWithInvalid() { // Test $actual = DeploymentSlot::isValid('invalid'); // Assert $this->assertFalse($actual); }
/** * Uploads a new service package and creates a new deployment on staging or * production. * * The createDeployment API is an asynchronous operation. To determine whether * the management service has finished processing the request, call * getOperationStatus API. * * @param string $name The name for the hosted service * that is unique within Windows Azure. * @param string $deploymentName The name for the deployment. * The deployment name must be unique among other deployments for the hosted * service. * @param string $slot The name of the deployment slot * This can be "production" or "staging". * @param string $packageUrl The URL that refers to the * location of the service package in the Blob service. The service package can * be located in a storage account beneath the same subscription. * @param string|resource $configuration The configuration file contents * or file stream. * @param string $label The name for the hosted service * that is base-64 encoded. The name can be up to 100 characters in length. It is * recommended that the label be unique within the subscription. The name can be * used identify the hosted service for your tracking purposes. * @param CreateDeploymentOptions $options The optional parameters. * * @return AsynchronousOperationResult * * @see http://msdn.microsoft.com/en-us/library/windowsazure/ee460813.aspx */ public function createDeployment($name, $deploymentName, $slot, $packageUrl, $configuration, $label, $options = null) { Validate::isString($name, 'name'); Validate::notNullOrEmpty($name, 'name'); Validate::isString($deploymentName, 'deploymentName'); Validate::notNullOrEmpty($deploymentName, 'deploymentName'); Validate::isString($slot, 'slot'); Validate::notNullOrEmpty($slot, 'slot'); Validate::isTrue(DeploymentSlot::isValid($slot), sprintf(Resources::INVALID_SLOT, $slot)); Validate::isString($packageUrl, 'packageUrl'); Validate::notNullOrEmpty($packageUrl, 'packageUrl'); Validate::isString($configuration, 'configuration'); Validate::notNullOrEmpty($configuration, 'configuration'); Validate::isString($label, 'label'); Validate::notNullOrEmpty($label, 'label'); if (is_null($options)) { $options = new CreateDeploymentOptions(); } $configuration = $this->_encodeConfiguration($configuration); $startDeployment = Utilities::booleanToString($options->getStartDeployment()); $treatWarningsAsErrors = Utilities::booleanToString($options->getTreatWarningsAsErrors()); $xmlElements = array(Resources::XTAG_NAME => $deploymentName, Resources::XTAG_PACKAGE_URL => $packageUrl, Resources::XTAG_LABEL => $label, Resources::XTAG_CONFIGURATION => $configuration, Resources::XTAG_START_DEPLOYMENT => $startDeployment, Resources::XTAG_TREAT_WARNINGS_AS_ERROR => $treatWarningsAsErrors); $requestXml = $this->_createRequestXml($xmlElements, Resources::XTAG_CREATE_DEPLOYMENT); $context = new HttpCallContext(); $context->setMethod(Resources::HTTP_POST); $context->setPath($this->_getDeploymentPathUsingSlot($name, $slot)); $context->addStatusCode(Resources::STATUS_ACCEPTED); $context->setBody($requestXml); $context->addHeader(Resources::CONTENT_TYPE, Resources::XML_CONTENT_TYPE); $response = $this->sendContext($context); return AsynchronousOperationResult::create($response->getHeader()); }