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

Commit d2daa31

Browse files
committed
Added pwsh az function container
1 parent b582232 commit d2daa31

File tree

4 files changed

+124
-7
lines changed

4 files changed

+124
-7
lines changed

containers/azure-functions-dotnetcore-2.2/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Azure Functions & C# (.NET Core Latest)
1+
# Azure Functions & Pwsh (.NET Core Latest)
22

33
## Summary
44

5-
*Develop Azure Functions in C#. Includes NET Core (Latest), the Azure Functions SDK, and related extensions and dependencies.*
5+
*Develop Azure Functions in PowerShell. Includes NET Core (Latest), the Azure Functions SDK, and related extensions and dependencies.*
66

77
| Metadata | Value |
88
|----------|-------|
99
| *Contributors* | The VS Code Team |
1010
| *Definition type* | Dockerfile |
11-
| *Languages, platforms* | Azure Functions, .NET Core, C# |
11+
| *Languages, platforms* | Azure Functions, .NET Core, PowerShell |
1212

1313
## Using this definition with an existing folder
1414

@@ -19,7 +19,7 @@ This definition requires an Azure subscription to use. You can create a [free ac
1919
2. To use VS Code's copy of this definition:
2020
1. Start VS Code and open your project folder.
2121
2. Press <kbd>F1</kbd> select and **Remote-Containers: Add Development Container Configuration Files...** from the command palette.
22-
3. Select the Azure Functions & C# (.NET Core Latest) definition.
22+
3. Select the Azure Functions & pwsh (.NET Core 2.2) definition.
2323

2424
3. To use latest-and-greatest copy of this definition from the repository:
2525
1. Clone this repository.
@@ -41,13 +41,13 @@ This definition includes some test code that will help you verify it is working
4141
5. After the folder has opened in the container, press <kbd>F1</kbd> and select **Azure Functions: Create Function...**.
4242
6. Enter these options:
4343
1. Yes (when prompted to create a new project)
44-
2. C#
44+
2. powershell
4545
3. HTTP Trigger
46-
4. HttpTriggerCSharp
46+
4. HttpTriggerPowerShell
4747
5. Anonymous
4848
6. Open in current window
4949
7. Press <kbd>F5</kbd> to start debugging project.
50-
8. After the debugger is started, open a local browser and enter the URL: `http://localhost:7071/api/HttpTriggerCSharp?name=remote`.
50+
8. After the debugger is started, open a local browser and enter the URL: `http://localhost:7071/api/HttpTriggerPowerShell?name=remote`.
5151
- If the port 7071 is not already open, press <kbd>F1</kbd>, select **Remote-Containers: Forward Port from Container...**, and then port 7071.
5252
9. You should see "Hello, remote" echoed by the Azure Function.
5353
10. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Azure Functions & pwsh (.NET Core 2.2)",
3+
"dockerFile": "Dockerfile",
4+
"appPort": 7071,
5+
// Use 'settings' to set *default* container specific settings.json values on container create.
6+
// You can edit these settings after create using File > Preferences > Settings > Remote.
7+
"settings": {
8+
"terminal.integrated.shell.linux": "/bin/bash"
9+
},
10+
// Uncomment the next line to run commands after the container is created.
11+
// "postCreateCommand": "dotnet restore",
12+
// Uncomment the next line to use a non-root user. On Linux, this will prevent
13+
// new files getting created as root, but you may need to update the USER_UID
14+
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
15+
// "runArgs": [ "-u", "vscode" ],
16+
// Add the IDs of extensions you want installed when the container is created in the array below.
17+
"extensions": [
18+
"ms-azuretools.vscode-azurefunctions",
19+
"ms-vscode.powershell"
20+
]
21+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
3+
4+
# Avoid warnings by switching to noninteractive
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
8+
# this user's GID/UID must match your local user UID/GID to avoid permission issues
9+
# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
10+
# https://aka.ms/vscode-remote/containers/non-root-user for details.
11+
ARG USERNAME=vscode
12+
ARG USER_UID=1000
13+
ARG USER_GID=$USER_UID
14+
15+
ARG PS_VERSION=6.2.3
16+
ARG PS_PACKAGE=powershell_${PS_VERSION}-1.debian.9_amd64.deb
17+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE}
18+
19+
# Download the Linux package and save it
20+
ADD ${PS_PACKAGE_URL} /tmp/powershell.deb
21+
22+
# Define ENVs for Localization/Globalization
23+
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
24+
LC_ALL=en_US.UTF-8 \
25+
LANG=en_US.UTF-8 \
26+
# set a fixed location for the Module analysis cache
27+
PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache
28+
29+
ENV FUNCTIONS_WORKER_RUNTIME=powershell
30+
31+
# Configure apt and install packages
32+
RUN apt-get update \
33+
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
34+
&& apt install -y /tmp/powershell.deb \
35+
#
36+
# Verify git and needed tools are installed
37+
&& apt-get -y install \
38+
git \
39+
iproute2 \
40+
procps \
41+
curl \
42+
apt-transport-https \
43+
gnupg2 \
44+
lsb-release \
45+
# less is required for help in powershell
46+
less \
47+
# requied to setup the locale
48+
locales \
49+
# required for SSL
50+
ca-certificates \
51+
gss-ntlmssp \
52+
&& apt-get dist-upgrade -y \
53+
# enable en_US.UTF-8 locale
54+
&& sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen \
55+
# generate locale
56+
&& locale-gen && update-locale \
57+
# remove powershell package
58+
&& rm /tmp/powershell.deb \
59+
#
60+
# Install Azure Functions and Azure CLI
61+
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list \
62+
&& 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 \
63+
&& curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
64+
&& apt-get update \
65+
&& apt-get install -y azure-cli azure-functions-core-tools \
66+
#
67+
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
68+
&& groupadd --gid $USER_GID $USERNAME \
69+
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
70+
# [Optional] Add sudo support for the non-root user
71+
&& apt-get install -y sudo \
72+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
73+
&& chmod 0440 /etc/sudoers.d/$USERNAME \
74+
#
75+
# Clean up
76+
&& apt-get autoremove -y \
77+
&& apt-get clean -y \
78+
&& rm -rf /var/lib/apt/lists/* \
79+
# intialize powershell module cache
80+
&& pwsh \
81+
-NoLogo \
82+
-NoProfile \
83+
-Command " \
84+
\$ErrorActionPreference = 'Stop' ; \
85+
\$ProgressPreference = 'SilentlyContinue' ; \
86+
while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \
87+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \
88+
Start-Sleep -Seconds 6 ; \
89+
}"
90+
91+
# Switch back to dialog for any ad-hoc use of apt-get
92+
ENV DEBIAN_FRONTEND=
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
README.md
2+
test-project
3+
.vscode
4+
.npmignore

0 commit comments

Comments
 (0)