diff --git a/containers/azure-functions-python-3/.devcontainer/Dockerfile b/containers/azure-functions-python-3/.devcontainer/Dockerfile new file mode 100644 index 0000000000..48b78d3429 --- /dev/null +++ b/containers/azure-functions-python-3/.devcontainer/Dockerfile @@ -0,0 +1,48 @@ +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- + +FROM python:3.6-stretch + +# Avoid warnings by switching to noninteractive +ENV DEBIAN_FRONTEND=noninteractive + +# Configure apt and install packages +RUN apt-get update \ + && apt-get -y install --no-install-recommends apt-utils 2>&1 \ + # + # Verify git and needed tools are installed + && apt-get -y install \ + git \ + procps \ + curl \ + apt-transport-https \ + gnupg2 \ + lsb-release \ + # + # Install Azure Functions, .NET Core, and Azure CLI + && echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list \ + && 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 \ + && curl -sL https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT) \ + && apt-get update \ + && apt-get install -y azure-cli dotnet-sdk-2.1 azure-functions-core-tools \ + # + # Install Docker CE CLI (needed for publish with --build-native-deps) + && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \ + && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \ + && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \ + && apt-get update \ + && apt-get install -y docker-ce-cli \ + # + # Install Docker Compose + && curl -sSL "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \ + && chmod +x /usr/local/bin/docker-compose \ + # + # Clean up + && apt-get autoremove -y \ + && apt-get clean -y \ + && rm -rf /var/lib/apt/lists/* + +# Switch back to dialog for any ad-hoc use of apt-get +ENV DEBIAN_FRONTEND=dialog diff --git a/containers/azure-functions-python-3/.devcontainer/devcontainer.json b/containers/azure-functions-python-3/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..29c0eb9ea9 --- /dev/null +++ b/containers/azure-functions-python-3/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// See https://aka.ms/vscode-remote/devcontainer.json for format details. +{ + "name": "Azure Functions & Python 3", + "dockerFile": "Dockerfile", + "appPort": [ 7071 ], + "runArgs": ["-v","/var/run/docker.sock:/var/run/docker.sock"], + + // Uncomment the next line if you want to add in default container specific settings.json values + "settings": { + "remote.extensionKind": { + "ms-azuretools.vscode-docker": "workspace" + } + }, + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "npm install", + + "extensions": [ + "ms-azuretools.vscode-azurefunctions", + "ms-python.python" + ] +} \ No newline at end of file diff --git a/containers/azure-functions-python-3/.npmignore b/containers/azure-functions-python-3/.npmignore new file mode 100644 index 0000000000..1d72d293eb --- /dev/null +++ b/containers/azure-functions-python-3/.npmignore @@ -0,0 +1,4 @@ +README.md +test-project +.vscode +.npmignore diff --git a/containers/azure-functions-python-3/README.md b/containers/azure-functions-python-3/README.md new file mode 100644 index 0000000000..bbe3b5a90a --- /dev/null +++ b/containers/azure-functions-python-3/README.md @@ -0,0 +1,59 @@ +# Azure Functions & Python 3 + +## Summary + +*Develop Azure Functions in Python. Includes Python 3, the Azure Functions SDK, Docker CLI (required to publish to Azure with native dependencies) and related extensions and dependencies.* + +| Metadata | Value | +|----------|-------| +| *Contributors* | [Anthony Chu](https://github.com/anthonychu) | +| *Definition type* | Dockerfile | +| *Languages, platforms* | Azure Functions, Python | + +## Using this definition with an existing folder + +This definition requires an Azure subscription to use. You can create a [free account here](https://azure.microsoft.com/en-us/free/serverless/) and learn more about using [Azure Functions with VS Code here](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code). Once you have an Azure account, follow these steps: + +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. + +2. To use VS Code's copy of this definition: + 1. Start VS Code and open your project folder. + 2. Press F1 select and **Remote-Containers: Add Development Container Configuration Files...** from the command palette. + 3. Select the Azure Functions & Python 3 definition. + +3. To use latest-and-greatest copy of this definition from the repository: + 1. Clone this repository. + 2. Copy the contents of `containers/azure-functions-python-3/.devcontainer` to the root of your project folder. + 3. Start VS Code and open your project folder. + +4. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs. + +5. Finally, press F1 and run **Remote-Containers: Reopen Folder in Container** to start using the definition. + +## Testing the definition + +This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps: + +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. +2. Clone this repository. +3. Start VS Code, press F1, and select **Remote-Containers: Open Folder in Container...** +4. Select the `containers/azure-functions-python-3` folder. +5. After the folder has opened in the container, press F1 and select **Azure Functions: Create Function...**. +6. Enter these options: + 1. Yes (when prompted to create a new project) + 2. Python + 3. HTTP Trigger + 4. HTTPTrigger + 5. Anonymous + 6. Open in current window +7. Press F5 to start debugging project. +8. After the debugger is started, open a local browser and enter the URL: `http://localhost:7071/api/HttpTrigger?name=remote`. + - If the port 7071 is not already open, press F1, select **Remote-Containers: Forward Port from Container...**, and then port 7071. +9. You should see "Hello remote" echoed by the Azure Function. +10. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing. + +## License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Licensed under the MIT License. See [LICENSE](https://github.com/Microsoft/vscode-dev-containers/blob/master/LICENSE).