Imad
Imad

Reputation: 2741

Can't download app content of azure function via portal

How do I download the source code of already-deployed Azure functions? The person who deployed this function has not versioned it in a repo yet, and the button is grayed out in the portal, as you can see.

Download button is grayed out

Upvotes: 4

Views: 8045

Answers (4)

Sebastian Rothbucher
Sebastian Rothbucher

Reputation: 1483

What works:

  • Log into azure
  • New tab
  • Go to https://FUNCTION_APP_NAME_HERE.scm.azurewebsites.net/api/settings
  • copy content of SCM_RUN_FROM_PACKAGE (which is a link)
  • another tab, go to http://... (the link given as SCM_RUN_FROM_PACKAGE)
  • you get a file with .zip extension, but it's not a ZIP
  • brew install squashfs (or whichever installer you need for your platform)
  • unsquashfs $zipfile
  • you have a new folder squahsfs-root
  • mv sqhashfs-root $(basename $file .zip)
  • (done)

Upvotes: 4

adam0101
adam0101

Reputation: 30995

You can also use the REST API to download. First log into Azure, then go to one of these urls depending on how your app is configured:

https://<function_app>.scm.azurewebsites.net/api/zip/site/wwwroot/

https://<function_app>.scm.azurewebsites.net/api/zip/data/SitePackages/

Warning! This will zip and download everything in the specified folder. To see what is in the folder before you download, you can snoop around using Bash by going here:

https://<function_app>.scm.azurewebsites.net/DebugConsole

You can also get to this by clicking on "Advanced Tools" from within the Function App UI in Azure.

Upvotes: 4

guspix
guspix

Reputation: 91

Since this is still the top post when searching for this problem, I'll add what I found for Python functions:

Following Monika's instructions I was able to ftp into the machine, but the wwwroot folder only had a host.json file. Looking around a bit I found that the actual zip files with the function's code were in the /data/SitePackages/ directory. Each file's name is a 14 digit number representing the upload date and time (yyyyMMddHHmmss). After unzipping the file I finally had access to the function's source code.

Upvotes: 3

Monika Reddy
Monika Reddy

Reputation: 963

You can download the app content of azure function via FTP into App Service using "Get publish Profile" in the portal.

  1. Once you login to the portal and click on app service.
  2. Then, you need to download the publish profile. Because publish profile contains all the credentials needed for you to FTP into the app service and download your source code. Click "Get Publish Profile" to download. enter image description here

  3. Once the publish profile is downloaded, open the note and extract the following content from the Note.

    • Publish Url
    • UserName
    • Password

enter image description here

  1. Once you have the credentials ready, you can FTP into the app service now. You can use any program you like in order to FTP into the app service. here I am giving an example of using FileZilla Client.
  2. Once you enter the credentials, click connect and expand the "Site" directory and right click the repository folder to download it.
  3. After downloading, navigate to the folder and you should be able to see your source code.

I hope this information helps.

Upvotes: 4

Related Questions