powershell - Python azure module: how to create a new deployment -


azure.servicemanagmentservice.py contains:

def create_deployment(self, service_name, deployment_slot, name,                           package_url, label, configuration,                           start_deployment=false,                           treat_warnings_as_error=false,                           extended_properties=none): 

what package_url , configuration? method comment indicates

 package_url:             url refers location of service package in             blob service. service package can located either in             storage account beneath same subscription or shared access             signature (sas) uri storage account. .... configuration:         base-64 encoded service configuration file deployment. 

all on internet there references visual studio , powershell create files. like? can manually create them? can azure module create them? why microsoft service confusing , lacks documentation?

i using https://pypi.python.org/pypi/azure python azure sdk. running mac os x on dev box, don't have visual studio or cspack.exe. appreciated. thank you.

according description, looks trying use python azure sdk create cloud service deployment. here documentation of how use create_deployment function.

can manually create them? can azure module create them?

if mean wanna know how create azure deployment package of python app, based on experience, there several options can leverage.

  • if have visual studio, can create cloud project projects’ template , package project via 1 click. in vs, create new project -> cloud -> enter image description here

then package project: enter image description here

after packaging project, have .cspkg file this: enter image description here

for better reference, have uploaded testing project at: https://onedrive.live.com/redir?resid=7b27a151cfceaf4f%21143283

as ‘configuration’, means base-64 encoded service configuration file (.cscfg) deployment enter image description here

in python, can set ‘configuration’ via below code

configuration = base64.b64encode(open('e:\\testprojects\\python\\yourprojectfolder\\serviceconfiguration.cloud.cscfg', 'rb').read()) 

hope above info provide quick clarification. now, let’s go python sdk , see how can use create_deployment function create cloud service deployment accordingly.

firstly, i’d suggest refer https://azure.microsoft.com/en-us/documentation/articles/cloud-services-python-how-to-use-service-management/ basic idea of azure service management , how it’s processing. in general, can make create_deployment function work via 5 steps

  1. create project’s deployment package , set configuration file (.cscfg) – (to have quick test, can use 1 have uploaded)
  2. store project’s deployment package in microsoft azure blob storage account under same subscription hosted service package being uploaded. blob file’s url (or use shared access signature (sas) uri storage account). can use azure storage explorer upload package file, , shown on azure portal. enter image description here
  3. use openssl create management certificate. needed create 2 certificates, 1 server (a .cer file) , 1 client (a .pem file), article mentioned have provided detailed info https://azure.microsoft.com/en-us/documentation/articles/cloud-services-python-how-to-use-service-management/

screenshot of created certificates enter image description here then, upload .cer certificate azure portal: settings -> management certificate tab -> click upload button (on bottom of page).

  1. create cloud service in azure , keep name in mind.
  2. create project test azure sdk - create_deployment, code snippet reference:

subscription_id = 'your subscription id found in azure portal'

certificate_path = 'e:\yourfoloder\mycert.pem'

sms = servicemanagementservice(subscription_id, certificate_path)  def testforcreateadeployment():     service_name = "your cloud service name"     deployment_name = "name"     slot = 'production'     package_url = ".cspkg file’s url – blob"     configuration = base64.b64encode(open('e:\\testprojects\\python\\ yourprojectfolder\\serviceconfiguration.cloud.cscfg ', 'rb').read())     label = service_name      result = sms.create_deployment(service_name,                  slot,                  deployment_name,                  package_url,                  label,                  configuration)        operation = sms.get_operation_status(result.request_id)       print('operation status: ' + operation.status) 

here running result’s screenshot: enter image description here enter image description here


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -