Justrebl / AzureFunction-unzipbigfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

From this Tutorial

  1. Local vs code azure function dev : Further Details
  2. Install azurite
  3. Start azurite :
    In Visual Studio Code : Ctrl + P > Azurite : Start 
    
  4. Configure Azure Function to use local development storage :
    {
    	"Values": {
    		"AzureWebJobsStorage": "UseDevelopmentStorage=true",
    		...
    	}
    }
  5. Install NGrok to tunnel the connection from internet :
  6. Set the token in the config :
    ngrok config add-authtoken <token>
  7. Create a custom endpoint (free and optional : Will help with keeping the same domain name for future tests) :
  8. Create an edge tunnel and configure it to the azure function host :
    ngrok config edit
    • Inside the file (retrieve the config from Cloud Edge > Edges > Start a Tunnel > Start a tunnel from a config file:
    version: 2
    authtoken: xxx
    tunnels:
      my_tunnel_name:
    	labels:
          - edge=xxx
        addr: http://localhost:80
  9. Manually serve the tunnel from the bash terminal :
    ngrok tunnel --label edge=edghts_2ShvSEl8k4SQImfDoMaECki0yop http://localhost:7071
  10. Configure the task.json (Java Sample) to expose the azure function to the internet :
    {
      "type":"shell",
      "label" : "Expose debug to internet",
      "command": "ngrok tunnel --label edge=edghts_2ShvSEl8k4SQImfDoMaECki0yop http://localhost:7071",
      "dependsOn": "func: host start"
    },
    {
      "type": "func",
      "label": "func: host start",
      "command": "host start",
      "problemMatcher": "$func-java-watch",
      "isBackground": true,
      "options": {
        "cwd": "${workspaceFolder}/target/azure-functions/unzipfunc-20230717151702055"
      },
      "dependsOn": "package (functions)"
    },
  11. Configure the launch.json to offer another debug option (calling the task.json):
    {
      "name": "Expose to Internet",
      "type": "java",
      "request": "attach",
      "hostName": "127.0.0.1",
      "port": 5005,
      "preLaunchTask": "Expose debug to internet"
    }
  12. Now the Azure function is running and exposed via the ngrok proxy, it's time to wire up Event Grid :
    1. Create an Event Grid System Topic Subscription from an Azure Storage Account Event tab for example
    2. Define the endpoint to HTTP Webhook as follows :
    https://<ngrok-endpoint>/runtime/webhooks/eventgrid?functionName=<FunctionName>
  13. In my example :
    https://carefully-awake-jennet.ngrok-free.app/runtime/webhooks/eventgrid?functionName=EventGridExample
  14. Then start everything together from vscode debug > Expose to Internet:
    1. Bare in mind that the reverse-proxy will be exposed via the token configured in the ngrok config edit step and communication remains encrypted through https

The source code can be found here : https://github.com/Justrebl/AzureFunction-unzipbigfiles

About


Languages

Language:Java 100.0%