{"id":15805222,"url":"https://github.com/ddobrin/azure-cloud-function-sample","last_synced_at":"2025-08-25T16:05:04.617Z","repository":{"id":134175479,"uuid":"328433032","full_name":"ddobrin/azure-cloud-function-sample","owner":"ddobrin","description":"Simple example of two Spring Cloud Functions running in Azure Functions, one generic and one tied into the Azure API","archived":false,"fork":false,"pushed_at":"2021-02-04T19:44:38.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-03T09:25:19.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddobrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-10T16:55:46.000Z","updated_at":"2021-02-04T19:44:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"761a70c0-75a7-4085-bd51-ab23efd319c5","html_url":"https://github.com/ddobrin/azure-cloud-function-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ddobrin/azure-cloud-function-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fazure-cloud-function-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fazure-cloud-function-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fazure-cloud-function-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fazure-cloud-function-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddobrin","download_url":"https://codeload.github.com/ddobrin/azure-cloud-function-sample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fazure-cloud-function-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272092448,"owners_count":24871953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T02:05:10.486Z","updated_at":"2025-08-25T16:05:04.564Z","avatar_url":"https://github.com/ddobrin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"This app builds 2 functions, built using different approaches:\n* `lowercase` - built as a generic function, can be run in any function service or locally\n* `uppercase` - built as a function integrated closely with the Azure CLI, can be run in Microsoft Azure or locally\n\nThe 2 approaches wish to illustrate a generic approach vs tight integration with a cloud provider API.\n\nThis document looks into:\n* building and running the functions to Azure\n* deployment to Azure Functions\n* debugging in a local environment\n\nYou can run these Azure functions locally, similar to other Spring Cloud Function samples, however this time by using the Azure Maven plugin, as the Microsoft Azure functions execution context must be available.\n\n## Build and package \n```shell\n# Build and package \n$ mvn clean package \n\n# Previously, for other examples\n$ mvn spring-boot:run\n\n# For Azure Functions\n$ mvn clean package azure-functions:run\n\nor \n\n$ mvn azure-functions:run\n```\n\nThe `uppercase` function takes `Function\u003cString, String\u003e uppercase()` and it's input is JSON, therefore we need to\nprovide the appropriate content-type (in this case `application/json`). The function iterates then over each element and returns its `uppercase` mapped value.\n\nTest the function using cURL or HTTPie and notice that the URL is formed by concatenating `\u003cfunction url\u003e/api/\u003cfunction name\u003e`\n```shell\n# testing with cURL\n$ curl -H \"Content-Type: application/json\" localhost:7071/api/uppercase -d '{\"greeting\": \"hello\", \"name\": \"your name\"}'\n\n# testing with HTTPie\n$ http POST localhost:7071/api/uppercase greeting=hello name='your name'\n\n# result\n{\n  \"greeting\": \"HELLO\",\n  \"name\": \"YOUR NAME\"\n}\n```\n\nThe `lowercase` function follows a similar approach for testing, with different endpoints and test cases:\n```shell\n# testing with cURL\n$ curl -H \"Content-Type: application/json\" localhost:7071/api/lowercase -d '{\"greeting\": \"HELLO\", \"name\": \"Your name\"}'\n\n# testing with HTTPie\n$ http POST localhost:7071/api/uppercase greeting=HELLO name='Your name'\n\n# result\n{\n  \"greeting\": \"hello\",\n  \"name\": \"your name\"\n}\n```\n## Deploy to Azure\nTo run locally on top of Azure Functions, and to deploy to your live Azure environment, you will need the Azure Functions Core Tools installed along with the Azure CLI (see https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven for more details).\n\nTo deploy the functions to your live Azure environment, including an automatic provisioning of an HTTPTrigger for the functions:\n```shell\n# login to Azure from the CLI\n$ az login\n\n# deploy the function\n$ mvn azure-functions:deploy\n\n[INFO] Authenticate with Azure CLI 2.0\n[INFO] The specified function app does not exist. Creating a new function app...\n[INFO] Successfully created the function app: function-sample-azure\n[INFO] Trying to deploy the function app...\n[INFO] Trying to deploy artifact to function-sample-azure...\n[INFO] Successfully deployed the artifact to https://function-sample-azure.azurewebsites.net\n[INFO] Successfully deployed the function app at https://function-sample-azure.azurewebsites.net\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n\n# Note: \n# the function URL is: https://function-sample-azure.azurewebsites.net\n# the function can be accessed at: https://function-sample-azure.azurewebsites.net/api/uppercase\n```\n\nOn another terminal try this: \n```shell\n# testing\ncurl https://\u003cazure-function-url-from-the-log\u003e/api/uppercase -d '{\"greeting\": \"hello\", \"name\": \"your name\"}'\n\n# testing with cURL\n$ curl -H \"Content-Type: application/json\" https://function-sample-azure.azurewebsites.net/api/uppercase -d '{\"greeting\": \"hello\", \"name\": \"your name\"}'\n\n# testing with HTTPie\n$ http POST https://function-sample-azure.azurewebsites.net/api/uppercase greeting=hello name='your name'\n\n# result\n{\n  \"greeting\": \"HELLO\",\n  \"name\": \"YOUR NAME\"\n}\n```\n\nfor `lowercase`, on another terminal try this: \n```shell\n# testing\ncurl https://\u003cazure-function-url-from-the-log\u003e/api/lowercase -d '{\"greeting\": \"HELLO\", \"name\": \"Your name\"}'\n\n# testing with cURL\n$ curl -H \"Content-Type: application/json\" https://function-sample-azure.azurewebsites.net/api/lowercase -d '{\"greeting\": \"HELLO\", \"name\": \"Your name\"}'\n\n# testing with HTTPie\n$ http POST https://function-sample-azure.azurewebsites.net/api/lowercase greeting=HELLO name='Your name'\n\n# result\n{\n  \"greeting\": \"hello\",\n  \"name\": \"your name\"\n}\n```\nPlease ensure that you use the right URL for the functions above. \n\nAlternatively you can test the function in the Azure Dashboard UI:\n\n* click on the Dashboard\n* click on the function app `function-sample-azure` \n* click on the left nav `Functions` and click the function name `uppercase`\n* click on the left nav `Code and Test` and at the top of the page `Test/Run`\n* In the body of the request, on the right-hand side, paste the same example we have used above:\n```shell\n{\n  \"greeting\": \"hello\",\n  \"name\": \"your name\"\n}\n\nobserve the HTTP response content\n{\n  \"greeting\": \"HELLO\",\n  \"name\": \"YOUR NAME\"\n}\n```\n\nFor `lowercase` testing:\n```shell \n* click on the left nav `Functions` and click the function name `lowercase`\n* click on the left nav `Code and Test` and at the top of the page `Test/Run`\n* In the body of the request, on the right-hand side, paste the same example we have used above:\n{\n  \"greeting\": \"HELLO\",\n  \"name\": \"Your name\"\n}\n```\nYou can observe the HTTP response content:\n```shell\n{\n  \"greeting\": \"hello\",\n  \"name\": \"your name\"\n}\n```\n\nPlease note that the Dashboard provides by default information on Function Execution Count, Memory Consumption and Execution Time.\n\n## Debug in a local environment\nIf you would like to debug the functions in your IDE, all you have to do is:\n```shell\n# start app locally\n# enableDebug opens the debug port in the current host at port 5005\n$ mvn azure-functions:run -DenableDebug\n```\n\nYou can start a remote debugging session in any IDE at `localhost` and port `5005`, set breakpoints and send requests.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fazure-cloud-function-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddobrin%2Fazure-cloud-function-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fazure-cloud-function-sample/lists"}