How to locally edit an already deployed function in Azure Functions (Python)? - python

After having worked on a Azure Functions application, i have now deployed the app and had it running for a while. Now I want to continue my work on another computer, however I cant seem to identify any way to download the source code in either VS Code nor Azure Portal?

For python function we can not download the content from Azure portal or VS code. It is in read-only mode.
Workaround:
1.Copy your project to another computer.
2.Create a new project on another computer and copy the main files from azure portal.
host.json and requirements.txt files from App files.
init.py and function.json files from Code+Test.

Related

Move python code from Azure Devops repo to windows Azure VM

We have a python application on a window azure VM that reads data from an API and loads the data into an onprem DB. The application works just fine and the code is source controlled in an Azure devops repo. The current deployment process is for someone to pull the main branch and copy the application from their local machine to c:\someapplication\ on the STAGE/PROD server. We would like to automate this process. There are a bunch of tutorials on how to do a build for API and Web applications which require your azure subscription and app name (which we dont have). My two questions are:
is there a way to do a simple copy to the c:\someapplication folder from azure devops for this application
if there is, would the copy solution be the best solution for this or should I consider something else?
Should i simply clone the main repo to each folder location above and then automate the git pull via the azure pipeline? Any advice or links would be greatly appreciated.
According to your description, you could try to use the CopyFiles#2 task and set the local folder as shared folder, so that use it as TargetFolder. The target folder or UNC path that will contain the copied files.
YAML like:
- task: CopyFiles#2
inputs:
SourceFolder:$(Build.SourcesDirectory) # string. Source Folder.
Contents: '**' # string. Required. Contents. Default: **.
TargetFolder: 'c:\\someapplication' # string. Required. Target Folder.
Please check if it meets your requirements.

How to run a Python Azure Function with a private Azure Artifact dependancy

I am trying to deploy a Python Azure Function into an Azure Function App. The function __init__.py script imports an SDK which is stored as an Azure Artifact Python Package. I can build and publish the function to Azure successfully using a pipeline from the DevOps repo, however the function fails at the import mySDK line when I run it.
I assume the issue is that because the function is serverless, when it is called the SDK needs to be pip installed again - how do I do this?
I have tried adding a PIP_EXTRA_INDEX_URL to the artifact feed in the Function App with no success.
PIP_EXTRA_INDEX_URL wored for me.
What was the issue you received when you tried it?
Basically before you deploy your function, you should alter the application settings on your function app and add the PIP_EXTRA_INDEX_URL key-value pair. Then add the python package in your azure artifacts feed to the requirements.txt file in your function app code.
There is a good guide here EasyOps - How To connect to azure artifact feed from Function App

how to view/edit files uploaded to Azure webapp?

I got my first flask webapp (hello.py) working (deployed) on Azure. I want to add more functionality to this webapp. According to documentation I am following
(https://medium.com/#nikovrdoljak/deploy-your-flask-app-on-azure-in-3-easy-steps-b2fe388a589e)
I should test my files (hello.py, home.html etc) locally and use git push to send new files to Azure cloud. I should restart my application to see changes.
(1) Is there a way to edit these files on Azure cloud using say emacs ?
(2) Related to (1) on which path do these files exist on Azure ? I clicked on cloudshell and a terminal popped up. It is apparently my home directory. I can see only one directory (clouddrive). I cannot see hello.py. I also went to .scm.azurewebsites.net and clicked on bash. I do get a command prompt but cannot see hello.py.
Thanks.
Under Development Tools you should have App Service Editor (Preview)
If you click on that it should allow you to edit the files via the portal.

Simple Google Cloud deployment: Copy Python files from Google Cloud repository to app engine

I'm implementing continuous integration and continuous delivery for a large enterprise data warehouse project.
All the code reside in Google Cloud Repository and I'm able to set up Google Cloud Build trigger, so that every time code of specific file type (Python scripts) are pushed to the master branch, a Google Cloud build starts.
The Python scripts doesn't make up an app. They contain an ODBC connection string and script to extract data from a source and store it as a CSV-file. The Python scripts are to be executed on a Google Compute Engine VM Instance with AirFlow installed.
So the deployment of the Python scripts is as simple as can be: The .py files are only to be copied from the Google Cloud repository folder to a specific folder on the Google VM instance. There is not really a traditionally build to run, as all the Python files are separate for each other and not part of an application.
I thought this would be really easy, but now I have used several days trying to figure this out with no luck.
Google Cloud Platform provides several Cloud Builders, but as far as I can see none of them can do this simple task. Using GCLOUD also does not work. It can copy files but only from local pc to VM not from source repository to VM.
What I'm looking for is a YAML or JSON build config file to copy those Python files from source repository to Google Compute Engine VM Instance.
Hoping for some help here.
The files/folders in the Google Cloud repository aren't directly accessible (it's like a bare git repository), you need to first clone the repo then copy the desired files/folders from the cloned repo to their destinations.
It might be possible to use a standard Fetching dependencies build step to clone the repo, but I'm not 100% certain of it in your case, since you're not actually doing a build:
steps:
- name: gcr.io/cloud-builders/git
args: ['clone', 'https://github.com/GoogleCloudPlatform/cloud-builders']
If not you may need one (or more) custom build steps. From Creating Custom Build Steps:
A custom build step is a container image that the Cloud Build worker
VM pulls and runs with your source volume-mounted to /workspace.
Your custom build step can execute any script or binary inside the
container; as such, it can do anything a container can do.
Custom build steps are useful for:
Downloading source code or packages from external locations
...

Deploying Django App on PythonAnywhere without using GitHub

I need to deploy a Django app on pythonanywhere, but I wish I could upload the code without using GitHub because I don't have private repositories and I don't want my codes to be exposed to the public.
How can I deploy my Django app on pythonanywhere without using GitHub?
According to their documentation, you can upload your project as zip to pythonanywhere. Have in mind that if the project is big enough you have to split it into parts.
Steps
Make a zip file ( split it to parts if needed)
Uploaded to pythonanywhere using the Files Tab
Use the bash console and the unzip command to decompress it
Done
More Info here
See the documentation of python anywhere
https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/

Categories

Resources