https://github.com/dcnsakthi/azfuncpy
Azure Function Python with VSCode Extension on Local and Azure.
https://github.com/dcnsakthi/azfuncpy
Last synced: 11 days ago
JSON representation
Azure Function Python with VSCode Extension on Local and Azure.
- Host: GitHub
- URL: https://github.com/dcnsakthi/azfuncpy
- Owner: dcnsakthi
- License: mit
- Created: 2021-11-22T08:45:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-22T11:31:52.000Z (over 3 years ago)
- Last Synced: 2025-02-17T17:52:49.963Z (3 months ago)
- Language: Python
- Size: 1.6 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Azure Function on Visual Studio Code (VSCode)
Note: Creating first Azure Function on Windows and Visual Studio Code with GitHub Repository.## 1. Create GitHub Repo
Prerequisite: [Sign up](https://github.com/join) for new GitHub account if you don't have already.
## 2. Clone GitHub Repo to Local
Prerequisite: Install Windows Git and VSCode if you don't have already.
## 3. Launch cloned repo in VSCode and create a new folder `http`
Prerequisite: Install VSCode if you don't have already.
## 4. Create Azure Function project from Command Palette (Ctrl+Shift+P)
Prerequisite: New directory (e.g., http) if you want to place generated code into separate directory.
1. Press `Ctrl+Shift+P` for Command Palette and type `Azure Functions: Create New Project..`
2. Select working directory `http` where the code should be generated
3. Select the Language as `Python` (Select your language of choice and following configurations.)
![]()
4. Create a Virtual Environment `Python` Version.
![]()
5. Enter function name as `nscsa` (as per your requirements).
6. Select Access Rights as `Anonymous` if you want to make this API as public.
![]()
## 5. Review the code under `http` directory and changes as required
Prerequisite: Python code should be generated (`__init__.py`) under `http` directory.
## 6. Run `Start Debugging` or Press `F5` to attach to Python Process (.venv)
Prerequisite: Auto Generated `host.json`, `function.json` and `local.settings.json` should exists under `http` directory.
```
host.json{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}```
```
local.settings.json{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python"
}
}
``````
function.json{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}```
## 7. Test the function with http request and Query Parameter using Browser
Prerequisite: Attach to Python Functions by `Start Debugging or Press F5` and Web Browser.
1. http URL request (`http://localhost:7071/api/nscsa`) using web browser
![]()
2. http URL request with Query Parameter (`http://localhost:7071/api/nscsa?name=World`) using web browser
## 8. Test the function with http request and Query Parameter using Postman
Prerequisite: Attach to Python Functions by `Start Debugging or Press F5` and Postman.
1. http URL requset (`http://localhost:7071/api/nscsa`) using Postman
![]()
2. http URL requset with Query Parameter (`http://localhost:7071/api/nscsa?name=World`) using Postman
## 9. Deploy to Azure Function using VSCode
Prerequisite: Successfully Build project (`http.csproj`) and Azure Subscription.
1. Create Azure Fucntion manually or use VSCode to Deploy directly with required inputs to Azure.
![]()
2. Sign-in to Azure using VSCode and Select the Azure Function target.
![]()
## 10. Test the function with http request and Query Parameter using Postman & Browser
Prerequisite: Successful deployment to Azure Function.
1. http URL requset with Query Parameter (`https://nscsa.azurewebsites.net/api/nscsa?name=Azure`) using Browser
2. http URL requset with Query Parameter (`https://nscsa.azurewebsites.net/api/nscsa?name=Azure`) using Postman
## 11. Commit and Push to GitHub
Prerequisite: GitHub Repo and Windows Git.
## 12. Continuous Deployment to Azure Function using GitHub Action
Prerequisite: GitHub Repo with updated code base.
Setup GitHub Action Workflow for Azire Function Deployment or Connect to GitHub from Azure Function.
---
Technology Used- VSCode
- VSCode Azure Function Extension
- Postman
- Browser
- Azure Subscription
- Azure Function
- GitHub
- Python 3.9Happy Learning !