Skip to content

isabella232/cloud-services-python-contoso-ads-application

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

services platforms author
cloud-services
python
msonecode

Python Contoso Ads Application Cloud Service

Introduction

Flask (Micro-framework for Python) version of the Contoso Ads application in Get started with Azure Cloud Services and ASP.NET.

Prerequisites

Note that only Python 3.4 and 2.7 are natively supported by Azure (Python 3.4 by default). If you prefer 2.7 or other versions, additional configuration for startup task is required.

2. Visual Studio 2013 or 2015

5. Azure Storage Account

Follow this guide to create a storage account and obtain the Access Key.

6. Azure Service Bus

Follow this guide to create a service bus and obtain the SAS key.

7. MongoDB

You may use MongoDB on Azure Virtual Machine or mLab.

Run the sample

1. Right click the project in the solution explorer and then choose Reload Project if it shows “unavailable”.

1 a

2. Modify the connection settings in WebRole1 > app > config.py.

MONGODB_SETTINGS ={
'db': 'your database name',
'host': 'your MongoDB host',
'port': port number,
'username': 'your user name',
'password': 'your password'
}

STORAGE_ACCOUNT_NAME = 'your storage account name'
STORAGE_ACCOUNT_KEY = 'storage access key'

SERVICEBUS_NAMESPACE = 'your servicebus namespace'
SERVICEBUS_ACCESS_KEYNAME = 'access key name'
SERVICEBUS_ACCESS_KEYVALUE = 'access key value'

3. Modify the connection settings in WorkerRole1 > config.py.

STORAGE_ACCOUNT_NAME = 'storage account name'
STORAGE_ACCOUNT_KEY = 'storage access key'

SERVICEBUS_NAMESPACE = 'servicebus namespace'
SERVICEBUS_ACCESS_KEYNAME = 'access key name'
SERVICEBUS_ACCESS_KEYVALUE = 'access key value'

MONGODB_NAME = 'your database name'
MONGODB_HOST = 'your MongoDB host'
MONGODB_PORT = port number
MONGODB_USERNAME = 'your user name'
MONGODB_PASSWORD = 'your password'

4. Right click the Python Environments section under the solution, remove the old virtual environment setting in WebRole1.

4

5. Add a new virtual environment in WebRole1.

5

6. Uncheck “Download and install packages” because we need to add some wheel files to local disk.

6

7. Repeat step 2 - 6 for WorkerRole1.

8. Find the .whl files in bin folder under WorkerRole1.

8

9. Create a bin folder in WorkerRole1 env folder and copy the .whl files to bin.

9

10. Repeat step 8 - 9 for WebRole1.

11. Run Install from requirements.txt for both virtual env.

11

12. To debug a particular role, right click on the role name and click "Set as StartUp Project".

12

Publish to Azure

You may follow this guide to publish the application to Azure Cloud Service.

Additional Information

1. We use wheels to install cffi, cryptograpy and Pillow library, because in Python 3.4 normal pip installation for these libraries may fail and return error "Unable to find vcvarsall.bat". If you can successfully install all references just by defining the name in requirements, you may safely skip above step 8 - 10.

2. Startup and Runtime task logs are located in the C:\Resources\Directory{role}\LogFiles folder in the Cloud Service instance. Check ConfigureCloudService.txt if any library in requirements.txt is not successfully installed. Check LaunchWorker.err.txt for WorkerRole runtime errors.

About

This project demonstrates how to build Python Contoso Ads Azure Cloud Service

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 37.4%
  • JavaScript 30.4%
  • HTML 30.3%
  • CSS 1.9%