diff --git a/.gitignore b/.gitignore index 3257a3d..8dbd7d3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ __pycache__/ *$py.class # Azure Functions -local.settings.json # Distribution / packaging .Python diff --git a/.vscode/settings.json b/.vscode/settings.json index 60e70c2..e06640d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,8 @@ "azureFunctions.projectLanguage": "Python", "azureFunctions.projectRuntime": "~4", "debug.internalConsoleOptions": "neverOpen", - "azureFunctions.projectLanguageModel": 2 + "azureFunctions.projectLanguageModel": 2, + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ] } \ No newline at end of file diff --git a/README.md b/README.md index 3d733d3..57c7fcc 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This source code supports the article [Quickstart: Create and deploy functions t ## Prerequisites + [Python 3.11](https://www.python.org/) ++ [Azurite](https://learn.microsoft.com/azure/storage/common/storage-use-azurite) (for local storage emulation) + [Azure Functions Core Tools](https://learn.microsoft.com/azure/azure-functions/functions-run-local?pivots=programming-language-python#install-the-azure-functions-core-tools) + [Azure Developer CLI (AZD)](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd) + To use Visual Studio Code to run and debug locally: @@ -46,24 +47,15 @@ You can initialize a project from this `azd` template in one of these ways: ```shell git clone https://github.com/Azure-Samples/functions-quickstart-python-http-azd.git - cd functions-quickstart-python-azd + cd functions-quickstart-python-http-azd ``` You can also clone the repository from your own fork in GitHub. -## Prepare your local environment +## Local settings -Add a file named `local.settings.json` in the root of your project with the following contents: +The `local.settings.json` file is included in this template with default values for local development. This file is excluded from deployment by `.funcignore`. -```json -{ - "IsEncrypted": false, - "Values": { - "AzureWebJobsStorage": "UseDevelopmentStorage=true", - "FUNCTIONS_WORKER_RUNTIME": "python" - } -} -``` ## Create a virtual environment @@ -86,7 +78,13 @@ py -m venv .venv ## Run your app from the terminal -1. To start the Functions host locally, run these commands in the virtual environment: +1. Start Azurite for local storage emulation. In a separate terminal, run: + + ```shell + azurite + ``` + +1. In your project terminal, start the Functions host: ```shell pip3 install -r requirements.txt diff --git a/infra/main.bicep b/infra/main.bicep index 9b333e5..337a436 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -110,7 +110,7 @@ module api './app/api.bicep' = { applicationInsightsName: monitoring.outputs.name appServicePlanId: appServicePlan.outputs.resourceId runtimeName: 'python' - runtimeVersion: '3.12' + runtimeVersion: '3.13' storageAccountName: storage.outputs.name enableBlob: storageEndpointConfig.enableBlob enableQueue: storageEndpointConfig.enableQueue diff --git a/local.settings.json b/local.settings.json new file mode 100644 index 0000000..3a10b64 --- /dev/null +++ b/local.settings.json @@ -0,0 +1,7 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "python" + } +} diff --git a/test.http b/test.http index 126f49e..b9b91d3 100644 --- a/test.http +++ b/test.http @@ -6,10 +6,10 @@ GET http://localhost:7071/api/httpget?name=World HTTP/1.1 ### -POST http://localhost:7071/api/httppost HTTP/1.1 +POST http://localhost:7071/api/httppost content-type: application/json { "name": "Awesome Developer", "age": 25 -} \ No newline at end of file +}