Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 59ba913

Browse files
committed
Fix Azure Functions Node defintions, add test projects
1 parent c31bcef commit 59ba913

File tree

28 files changed

+424
-42
lines changed

28 files changed

+424
-42
lines changed

containers/azure-functions-node-8/.devcontainer/Dockerfile

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM mcr.microsoft.com/dotnet/core/sdk:2.1
6+
FROM node:8
77

88
# Configure apt
99
ENV DEBIAN_FRONTEND=noninteractive
@@ -19,32 +19,15 @@ RUN apt-get -y install \
1919
gnupg2 \
2020
lsb-release
2121

22-
# Install Node.js via NVM - See https://github.com/creationix/nvm
23-
# Change the number "8" in the two lines below to pick a different version
24-
RUN curl -so- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 2>&1 \
25-
&& /bin/bash -c "source $HOME/.nvm/nvm.sh \
26-
&& nvm install --no-progress 8 \
27-
&& nvm alias default 8" 2>&1
28-
29-
# Install eslint
30-
RUN /bin/bash -c "source $HOME/.nvm/nvm.sh && npm install -g eslint"
31-
32-
# Install latest yarn
33-
RUN curl -sS https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/pubkey.gpg | apt-key add - 2>/dev/null \
34-
&& echo "deb https://dl.yarnpkg.com/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
35-
&& apt-get update \
36-
&& apt-get -y install --no-install-recommends yarn
37-
38-
# Install Azure Functions and Azure CLI
22+
# Install Azure Functions, .NET Core, and Azure CLI
3923
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list \
4024
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list \
41-
&& curl -sL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 2>/dev/null \
25+
&& curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
4226
&& apt-get update \
43-
&& apt-get install -y azure-cli azure-functions-core-tools
27+
&& apt-get install -y azure-cli dotnet-sdk-2.1 azure-functions-core-tools
4428

4529
# Clean up
4630
RUN apt-get autoremove -y \
4731
&& apt-get clean -y \
4832
&& rm -rf /var/lib/apt/lists/*
4933
ENV DEBIAN_FRONTEND=dialog
50-
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+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
"cwd": "${workspaceFolder}/test-project",
10+
"preLaunchTask": "func: host start"
11+
}
12+
]
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"azureFunctions.projectRuntime": "~2",
3+
"azureFunctions.projectLanguage": "JavaScript",
4+
"azureFunctions.deploySubpath": ".",
5+
"azureFunctions.preDeployTask": "func: extensions install",
6+
"files.exclude": {
7+
"obj": true,
8+
"bin": true
9+
},
10+
"debug.internalConsoleOptions": "neverOpen"
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"command": "host start",
7+
"problemMatcher": "$func-watch",
8+
"dependsOn": "func: extensions install",
9+
"isBackground": true
10+
},
11+
{
12+
"label": "PATH",
13+
"type": "shell",
14+
"command": "echo $PATH"
15+
}
16+
]
17+
}

containers/azure-functions-node-8/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ This definition requires an Azure subscription to use. You can create a [free ac
3030

3131
5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** to start using the definition.
3232

33+
## Testing the definition
34+
35+
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
36+
37+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
38+
2. Clone this repository.
39+
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
40+
4. Select the `containers/azure-functions-node-8` folder.
41+
5. After the folder has opened in the container, press <kbd>F5</kbd> to start the project.
42+
6. After the debugger is started, open a local browser and enter the URL: `http://localhost:7071/api/HttpTrigger?name=remote`.
43+
7. You should see "Hello remote" echoed by the Azure Function.
44+
8. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing.
45+
3346
## License
3447

3548
Copyright (c) Microsoft Corporation. All rights reserved.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git*
2+
.vscode
3+
local.settings.json
4+
test
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# TypeScript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
.env.test
60+
61+
# parcel-bundler cache (https://parceljs.org/)
62+
.cache
63+
64+
# next.js build output
65+
.next
66+
67+
# nuxt.js build output
68+
.nuxt
69+
70+
# vuepress build output
71+
.vuepress/dist
72+
73+
# Serverless directories
74+
.serverless/
75+
76+
# FuseBox cache
77+
.fusebox/
78+
79+
# DynamoDB Local files
80+
.dynamodb/
81+
82+
# Azure Functions artifacts
83+
bin
84+
obj
85+
appsettings.json
86+
local.settings.json
87+
88+
# TypeScript output
89+
dist
90+
out
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "anonymous",
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+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = async function (context, req) {
2+
context.log('JavaScript HTTP trigger function processed a request.');
3+
4+
if (req.query.name || (req.body && req.body.name)) {
5+
context.res = {
6+
// status: 200, /* Defaults to 200 */
7+
body: "Hello " + (req.query.name || req.body.name)
8+
};
9+
}
10+
else {
11+
context.res = {
12+
status: 400,
13+
body: "Please pass a name on the query string or in the request body"
14+
};
15+
}
16+
};

0 commit comments

Comments
 (0)