I have a Python WebJob living in Azure and I'm trying to pass parameters to it.
I've found documentation saying that I should be able to post the URL and add:?arguments={'arg1', 'arg2'} after it.
However, when I do that and then try to print(sys.argv) in my code, it's only printing the name of the Python file and none of the arguments I pass to it.
How do I get the arguments to pass to my Python code? I am also using a run.cmd in my Azure directory to trigger my Python code if that makes a difference.
UPDATE: So I tested it in another script without the run.cmd and that certainly is the problem. If I just do ?arguments=22 66 it works. So how do I pass parameters when I'm using a run.cmd file?
I figured it out: in the run.cmd file, you need to put "%*" after your script name and it will detect any arguments you passed in the URL.
If anyone is looking to pass named parameter, then add it in the url like:
url?arguments=--arg1 val1 --arg2 "val2" --arg3 0.99
Related
I am trying to get the application settings values from azure function for python.
I used the below code to get the Data_AzureConnection value.
logging.info("OS Env")
logging.info("Env value")
test = os.environ["Data_AzureConnection"]
logging.info(test)
But I got below result
Why I am not able to see the Data_AzureConnection value?
Is there any way to get the values from azure function for python application settings?
Please let me know if there is a solution.
It only shows Hidden Credential in the log, actually you can get it in the code by using os.environ["Data_AzureConnection"]. It returns the value in the reponse, see my test result below.
I am actually working on a TACTIC project which uses AngularJS on the frontend and Python scripts on the backend.
Here when the python script is executed using server.execute_cmd(cls_name,args) from the Javascript code, the python script is run, BUT isn't able to return a value back to the front-end!
To return any o/p back to the calling function, you need to populate and return self.info
self.info["your_key_here"] = [your_answer]
In this way, the front-end or the calling command will receive the desired return value. I hope this answers helps others who have had/or will have similar query in future.
I have a python script that is written in different files (one for importing, one for calculations, et cetera). These are all in the same folder, and when I need a function from another function I do something like
import file_import
file_import.do_something_usefull()
where, of course, in the file_import there is a function do_something_usefull() that, uhm, does something usefull. How can I accomplish the same in Azure?
I found it out myself. It is documenten on Microsoft's site here.
The steps, very short, are:
Include all the python you want in a .zip
Upload that zip as a dataset
Drag the dataset as the third option parameter in the 'execute python'-block (example below)
execute said function by importing import Hello (the name of the file, not the zip) and running Hello.do_something_usefull()
As reference, there is a similiar answered thread you can refer to, please see Access Azure blog storage from within an Azure ML experiment.
Let say I'm creating an issue in Jira and write the summary and the description. Is it possible to call a python script after these are written that sets the value for another field, depending on the values of the summary and the description?
I know how to create an issue and change fields from a python script using the jira-python module. But I have not find a solution for using a python script while editing/creating the issue manually in Jira. Does anyone have an idea of how I manage that?
I solved the problem by using the Add-on Script runner in Jira. There I created a scripted field in Groovy and called the command prompt and run the python script from there. Here is a simple example of the script
def process = ['cmd', '/c', 'filepathToPython.exe', 'filepathToPythonFile.py'].execute()
process.waitfor()
return p.text
process?.err?.text can be used instead of process.text if one want to see eventual error messages.
Take a look at JIRA webhooks calling a small python based web server?
I am trying to get the query string in a CGI python script because for some reason the .FieldStorage and .getvalue functions are returning "None". The query is being generated correctly. I checked it in Wireshark and it is correctly produced.
Any ideas on how I can just get the string itself correctly?
I was trying to use os.environ('QUERY_STRING') but that didn't work either.
Josh
I think I figured it out. I need to use the environ variable passed to the application function by mod_wsgi.
Thanks!