How i get IP Address from this request HTTP using python? I found some posts using C#, like this: Get remote IP address in Azure function
I have this code:
import logging
import json
import socket
import getpass
import os
from requests import get
import azure.functions as func
from azure.common.client_factory import get_client_from_json_dict,get_client_from_cli_profile
from azure.mgmt.sql import SqlManagementClient
from azure.mgmt.resource import SubscriptionClient
from azure.common.credentials import ServicePrincipalCredentials
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
Myip = get('https://api.ipify.org').text
username = getpass.getuser()
return func.HttpResponse(
f"List of IPs: {str(Myip)}",
status_code=200
)
The image shows the result of the local request.