An open API service indexing awesome lists of open source software.

https://github.com/dcnsakthi/azfunc

Azure Function .NET Core with VSCode Extension on Local and Azure.
https://github.com/dcnsakthi/azfunc

Last synced: 9 days ago
JSON representation

Azure Function .NET Core with VSCode Extension on Local and Azure.

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 `C#` (Select your language of choice and following configurations.)



4. Select the runtime as `.NET Core 3 LTS`



5. Enter function name and namespace `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: C# code should be generated (`nscsa.cs`) under `http` directory.

## 6. Run `Start Debugging` or Press `F5` to attach to .NET Process

Prerequisite: Auto Generated `host.json` and `local.settings.json` should exists under `http` directory.
```
host.json

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
```

```
local.settings.json

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
```

## 7. Test the function with http request and Query Parameter using Browser

Prerequisite: Attach to .NET 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 .NET Functions by `Start Debugging or Press F5` and Postman.

1. http URL request (`http://localhost:7071/api/nscsa`) using Postman



2. http URL request 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 Function 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 request with Query Parameter (`https://nscsa.azurewebsites.net/api/nscsa?name=Azure`) using Browser



2. http URL request 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 Azure Function Deployment or Connect to GitHub from Azure Function.

---
Technology Used

- VSCode
- VSCode Azure Function Extension
- Postman
- Browser
- Azure Subscription
- Azure Function
- GitHub
- .NET Core 3

Happy Learning !