Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

How can you deploy an Azure Function from within a Python script

In the same way that you would deploy a storage account or a upload a blob file from Python.

I am essentially looking for the Python equivalent of the following bash commands

  1. az functionapp create --resource-group $RESOURCE_GROUP_NAME --os-type Linux --consumption-plan-location $AZ_LOCATION --runtime python --runtime-version 3.6 --functions-version 2 --name $APP_NAME --storage-account $STORAGE_ACCOUNT_NAME

  2. func new --name $FUNC_NAME --template "Azure Queue Storage trigger"

  3. func azure functionapp publish $APP_NAME --build-native-deps

A cop-out would be to just have the Python script run the shell commands, but I am looking for a more elegant solution if one exists.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am essentially looking for the Python equivalent of the following bash commands

If you check the python sdk of azure or check the REST API document of azure, you will find there is no Ready-made method.Basically, there are two situations to discuss:

If you want to deploy azure function to windows OS, then just use any python code to upload local function structure to related storage file share(The premise is that the function app has been created on azure.).

But if you want to deploy azure function to linux OS, then it will not be as simple as deploying to windows OS. It needs to perform additional packaging operations, and the specific logic may need to check the underlying implementation of azure cli.

A cop-out would be to just have the Python script run the shell commands, but I am looking for a more elegant solution if one exists.

For Linux-based azure function, I think you don’t have to consider so much. It has many additional operations when deploy function app, so use command or run command by python to achieve this is more recommended(There is no ready-made python code or REST API that can do what you want.).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...