Skip to content

Commit 04f2f36

Browse files
committed
first azure function
0 parents  commit 04f2f36

File tree

16 files changed

+869
-0
lines changed

16 files changed

+869
-0
lines changed

.funcignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.js.map
2+
*.ts
3+
.git*
4+
.vscode
5+
__azurite_db*__.json
6+
__blobstorage__
7+
__queuestorage__
8+
local.settings.json
9+
test
10+
tsconfig.json

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (https://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# TypeScript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
.env.test
64+
65+
# parcel-bundler cache (https://parceljs.org/)
66+
.cache
67+
68+
# next.js build output
69+
.next
70+
71+
# nuxt.js build output
72+
.nuxt
73+
74+
# vuepress build output
75+
.vuepress/dist
76+
77+
# Serverless directories
78+
.serverless/
79+
80+
# FuseBox cache
81+
.fusebox/
82+
83+
# DynamoDB Local files
84+
.dynamodb/
85+
86+
# TypeScript output
87+
dist
88+
out
89+
90+
# Azure Functions artifacts
91+
bin
92+
obj
93+
appsettings.json
94+
local.settings.json
95+
96+
# Azurite artifacts
97+
__blobstorage__
98+
__queuestorage__
99+
__azurite_db*__.json

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions"
4+
]
5+
}

.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Node Functions",
6+
"type": "node",
7+
"request": "attach",
8+
"port": 9229,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"azureFunctions.deploySubpath": ".",
3+
"azureFunctions.postDeployTask": "npm install (functions)",
4+
"azureFunctions.projectLanguage": "TypeScript",
5+
"azureFunctions.projectRuntime": "~4",
6+
"debug.internalConsoleOptions": "neverOpen",
7+
"azureFunctions.preDeployTask": "npm prune (functions)"
8+
}

.vscode/tasks.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"label": "func: host start",
7+
"command": "host start",
8+
"problemMatcher": "$func-node-watch",
9+
"isBackground": true,
10+
"dependsOn": "npm build (functions)"
11+
},
12+
{
13+
"type": "shell",
14+
"label": "npm build (functions)",
15+
"command": "npm run build",
16+
"dependsOn": "npm clean (functions)",
17+
"problemMatcher": "$tsc"
18+
},
19+
{
20+
"type": "shell",
21+
"label": "npm install (functions)",
22+
"command": "npm install"
23+
},
24+
{
25+
"type": "shell",
26+
"label": "npm prune (functions)",
27+
"command": "npm prune --production",
28+
"dependsOn": "npm build (functions)",
29+
"problemMatcher": []
30+
},
31+
{
32+
"type": "shell",
33+
"label": "npm clean (functions)",
34+
"command": "npm run clean",
35+
"dependsOn": "npm install (functions)"
36+
}
37+
]
38+
}

HttpTrigger1/function.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "function",
5+
"type": "httpTrigger",
6+
"direction": "in",
7+
"name": "req",
8+
"methods": [
9+
"get",
10+
"post"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "res"
17+
}
18+
],
19+
"scriptFile": "../dist/HttpTrigger1/index.js"
20+
}

HttpTrigger1/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
2+
3+
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
4+
context.log('HTTP trigger function processed a request.');
5+
const name = (req.query.name || (req.body && req.body.name));
6+
const responseMessage = name
7+
? "Hello, " + name + ". This HTTP triggered function executed successfully."
8+
: "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";
9+
10+
context.res = {
11+
// status: 200, /* Defaults to 200 */
12+
body: responseMessage
13+
};
14+
15+
};
16+
17+
export default httpTrigger;

HttpTrigger1/sample.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "Azure"
3+
}

TimerTrigger1/function.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "myTimer",
5+
"type": "timerTrigger",
6+
"direction": "in",
7+
"schedule": "0 */5 * * * *"
8+
}
9+
],
10+
"scriptFile": "../dist/TimerTrigger1/index.js"
11+
}

0 commit comments

Comments
 (0)