'Azure HTTP Function works localy but not on azure / Azure URL gives result website cant be found
I'am working on Azure HTTP function, what I'am trying to achieve is:
Azure function based on python after calling via URL it shall connect to Linux VPS execute command and return the response from VPS.
It does exactly that after running it on localhost via Visual Studio code

Then exactly same code is uploaded via Azure Pipeline which runs without issues However after calling function via Azure URL it gives 404 error. Function IS enabled and Code is uploaded sucessfully and can be seen in 'Code + Test' section
import logging
import azure.functions as func
import sys
import paramiko
def execute_command_on_remote_machine(ip_addr, command):
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(str(ip_addr), username='username', password='password')
chan = client.get_transport().open_session()
#chan.get_pty()
stdout = [], [], []
stdout = client.exec_command(command, get_pty=True)
#err_list = [line for line in stderr.read().splitlines()]
out_list = [line for line in stdout.read().splitlines()]
client.close()
return out_list
except Exception as e:
print(str(e))
sys.exit(1)
def main(req: func.HttpRequest) -> func.HttpResponse:
output = execute_command_on_remote_machine("IP", "sh /home/script.sh")
logging.info(str(output))
return func.HttpResponse(str(output))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
