Freigeben über


Create a new Azure Apiapp in python supporting swagger 2.0

 

An API app is an App Service web app with additional features that enhance the experience of developing, deploying, publishing, consuming, managing, and monetizing RESTful web APIs.

For More information Please refer : https://azure.microsoft.com/en-us/documentation/articles/app-service-api-apps-why-best-platform/

 

This Blog would provide steps to create a sample Azure API APP in Python using Flask-restplus

1) Add a new virtual environment proxy file(ptvs_virtualenv_proxy.py).sample file is available @ https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#virtual-environment-proxy

2) Create a requirements.txt file with below content. Find more details about package management @ https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#package-management

 flask-restplus==0.7.2 

3) Get a sample flask-restplus code available @ https://flask-restplus.readthedocs.org/en/latest/example.html. I have placed my code in api.py file

4) Create a new folder and add a web.config file in your local workspace. You can find a sample @ https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#webconfig

Change value of WSGI_ALT_VIRTUALENV_HANDLER in web.config as required. I have mentioned it as api.app because my sample code was in api.py file with app as main method in it.

5) Create a new file apiapp.json at root folder

 {
 "$schema": "https://json-schema.org/schemas/2014-11-01/apiapp.json#",
 "id": "Bumblebee",
 "namespace": "microsoft.com",
 "gateway": "2015-01-14",
 "version": "1.9.0",
 "title": "Bumblebee",
 "summary": "",
 "author": "",
 "endpoints": {
 "apiDefinition": "/swagger",
 "status": null
 }
}

6) At the end you would see below list of files

 

Please find more details on creating and deploying Azure API app at below link

https://azure.microsoft.com/en-us/documentation/articles/app-service-api-nodejs-api-app/

 

After deploying your app, you should be able to see app definition in portal as below

 

Similar Links :

Troubleshoot Azure API APP - https://blogs.msdn.com/b/azureossds/archive/2015/06/01/troubleshoot-azure-api-app.aspx

Create a NodeJs API APP - https://blogs.msdn.com/b/azureossds/archive/2015/06/01/creating-a-nodejs-api-app.aspx

Comments

  • Anonymous
    September 08, 2016
    Thank you for the above information, I have a similar requirement in which I have to create an Azure API app from .YAML file . Can you help me by telling the process to follow for this task. FYI - I have with me a .yaml file , some .py file and some .html file and the idea is to create the API app using .yaml file.