Method: Azure::CloudServiceManagement::CloudServiceManagementService#create_deployment

Defined in:
lib/azure/cloud_service_management/cloud_service_management_service.rb

#create_deployment(deployment_name, cloud_service_name, package_url, service_configuration, options = {}) ⇒ Object

Public: Deploy a .cspkg hosted at a specific package_url to a a Cloud Service on a specific slot

Attributes

  • deployment_name - String. Name of the deployment

  • cloud_service_name - String. Name of the Cloud Service where the deployment

    needs to be created
    
  • package_url - String. URL of the blob storage where the .cspkg is being

    stored
    
  • package_url - String. URL of the blob storage where the .cspkg is being

    stored
    
  • service_configuration - Base64 encoded String. ServiceConfiguration.cscfg file

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :slot - String. Deployment slot. Valid values are either

    'production'(default) or 'staging'.
    
  • :label - String. The label for this cloud service.

  • :start_deployment - String. A description for the hosted service. (optional)

  • :treat_warnings_as_error - String.

  • :extended_properties - Hash. Key/Value pairs of extended properties to add to

    the cloud service. The key is used as the property name 
    and the value as its value.
    
  • fire_and_forget - Boolean(efault is false). If true, the client

    does not wait until the request is completed.
    
  • :upgrade_if_exists - Boolean(default is false). If true, then if a deployment

    already exists, then it is upgraded. Otherwise, an exception 
    is thrown.
    

More details at msdn.microsoft.com/en-us/library/azure/ee460813.aspx

Returns None



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/azure/cloud_service_management/cloud_service_management_service.rb', line 96

def create_deployment(deployment_name, cloud_service_name, package_url, service_configuration, options = {})
  Loggerx.error_with_exit 'Cloud service name is not valid' unless cloud_service_name
  Loggerx.error_with_exit 'Deployment name is not valid' unless deployment_name
  Loggerx.error_with_exit 'Package url is not valid' unless package_url
  Loggerx.error_with_exit 'ServiceConfiguration.cscfg is not valid' unless service_configuration
  upgrade_if_exists = options[:upgrade_if_exists].nil? ? false : options[:upgrade_if_exists]

  slot = "production"
  unless options.nil? || options[:slot].nil?
    valid_slot = options[:slot].casecmp("staging") || options[:slot].casecmp("production")
    Loggerx.error_with_exit 'Deployment slot is not valid' unless valid_slot
    slot = options[:slot].downcase
  end

  # 2. Get the current deployment so one can verify that it can be upgraded
  deployment = get_deployment(cloud_service_name, {:slot => slot, :no_exit_on_failure => true})

  # 3. Create or upgrade the deployment
  if deployment.exists?
    if upgrade_if_exists
      upgrade_deployment(cloud_service_name, package_url, service_configuration, options)
    else
      Loggerx.error_with_exit "#{slot.capitalize} deployment '#{deployment_name}' on cloud service #{cloud_service_name} already exist."
    end
  else
    slot = "production"
    unless options.nil? || options[:slot].nil?
      valid_slot = options[:slot].casecmp("staging") || options[:slot].casecmp("production")
      Loggerx.error_with_exit 'Deployment slot is not valid' unless valid_slot
      slot = options[:slot].downcase
    end
    Loggerx.info "Creating deployment #{deployment_name}."
    request_path = "/services/hostedservices/#{cloud_service_name}/deploymentslots/#{slot}"
    body = Serialization.create_deployment_to_xml(deployment_name, package_url, service_configuration, options)
    request = ManagementHttpRequest.new(:post, request_path, body)
    request.call(options)
  end
end