Hendelser
17. mars, 21 - 21. mars, 10
Bli med i meetup-serien for å bygge skalerbare AI-løsninger basert på virkelige brukstilfeller med andre utviklere og eksperter.
Registrer deg nåDenne nettleseren støttes ikke lenger.
Oppgrader til Microsoft Edge for å dra nytte av de nyeste funksjonene, sikkerhetsoppdateringene og den nyeste tekniske støtten.
In Azure, you can run your functions directly from a deployment package file in your function app. The other option is to deploy your files in the c:\home\site\wwwroot
(Windows) or /home/site/wwwroot
(Linux) directory of your function app.
This article describes the benefits of running your functions from a package. It also shows how to enable this functionality in your function app.
There are several benefits to running functions from a package file:
For more information, see this announcement.
Function apps on the Flex Consumption hosting plan run from a package by default. No special configuration needs to be done.
To enable your function app to run from a package on the Consumption, Elastic Premium, and Dedicated (App Service) hosting plans, add a WEBSITE_RUN_FROM_PACKAGE
app setting to your function app. The WEBSITE_RUN_FROM_PACKAGE
app setting can have one of the following values:
Value | Description |
---|---|
1 |
Indicates that the function app runs from a local package file deployed in the c:\home\data\SitePackages (Windows) or /home/data/SitePackages (Linux) folder of your function app. |
<URL> |
Sets a URL that is the remote location of the specific package file you want to run. Required for functions apps running on Linux in a Consumption plan. |
The following table indicates the recommended WEBSITE_RUN_FROM_PACKAGE
values for deployment to a specific operating system and hosting plan:
Hosting plan | Windows | Linux |
---|---|---|
Consumption | 1 is highly recommended. |
Only <URL> is supported. |
Premium | 1 is recommended. |
1 is recommended. |
Dedicated | 1 is recommended. |
1 is recommended. |
WEBSITE_RUN_FROM_PACKAGE
app setting to apps on the Flex Consumption plan.WEBSITE_RUN_FROM_PACKAGE
to 1
and publish with zip deployment.wwwroot
folder is read-only and you receive an error if you write files to this directory. Files are also read-only in the Azure portal.WEBSITE_RUN_FROM_PACKAGE
app setting. Instead, add the SCM_DO_BUILD_DURING_DEPLOYMENT=true
deployment customization app setting. For Linux, also add the ENABLE_ORYX_BUILD=true
setting. For more information, see Remote build.Obs!
The WEBSITE_RUN_FROM_PACKAGE
app setting does not work with MSDeploy as described in MSDeploy VS. ZipDeploy. You will receive an error during deployment, such as ARM-MSDeploy Deploy Failed
. To resolve this error, change /MSDeploy
to /ZipDeploy
.
There are several ways that you can add, update, and delete function app settings:
Changes to function app settings require your function app to be restarted.
The zip archive you deploy must contain all of the files needed to run your function app. You can manually create a zip archive from the contents of a Functions project folder using built-in .zip compression functionality or third-party tools.
The archive must include the host.json file at the root of the extracted folder. The selected language stack for the function app creates additional requirements:
Viktig
For languages that generate compiled output for deployment, make sure to compress the contents of the output folder you plan to publish and not the entire project folder. When Functions extracts the contents of the zip archive, the host.json
file must exist in the root of the package.
This section provides information about how to run your function app from a local package file.
c:\home\data\SitePackages
(Windows) or /home/data/SitePackages
(Linux) folder has a file named packagename.txt
. This file contains only the name, without any whitespace, of the package file in this folder that's currently running.Zip deployment is a feature of Azure App Service that lets you deploy your function app project to the wwwroot
directory. The project is packaged as a .zip deployment file. The same APIs can be used to deploy your package to the c:\home\data\SitePackages
(Windows) or /home/data/SitePackages
(Linux) folder.
When you set the WEBSITE_RUN_FROM_PACKAGE
app setting value to 1
, the zip deployment APIs copy your package to the c:\home\data\SitePackages
(Windows) or /home/data/SitePackages
(Linux) folder instead of extracting the files to c:\home\site\wwwroot
(Windows) or /home/site/wwwroot
(Linux). It also creates the packagename.txt
file. After your function app is automatically restarted, the package is mounted to wwwroot
as a read-only filesystem. For more information about zip deployment, see Zip deployment for Azure Functions.
Obs!
When a deployment occurs, a restart of the function app is triggered. Function executions currently running during the deploy are terminated. For information about how to write stateless and defensive functions, sett Write functions to be stateless.
This section provides information about how to run your function app from a package deployed to a URL endpoint. This option is the only one supported for running from a Linux-hosted package with a Consumption plan. This option is not supported in the Flex Consumption plan.
WEBSITE_RUN_FROM_PACKAGE = <URL>
in apps on the Flex Consumption plan. This option is not supported.WEBSITE_RUN_FROM_PACKAGE = <URL>
.To deploy a zipped package when using the URL option, you must create a .zip compressed deployment package and upload it to the destination. The following procedure deploys to a container in Blob Storage:
Create a .zip package for your project using the utility of your choice.
In the Azure portal, search for your storage account name or browse for it in the storage accounts list.
In the storage account, select Containers under Data storage.
Select + Container to create a new Blob Storage container in your account.
In the New container page, provide a Name (for example, deployments), ensure the Anonymous access level is Private, and then select Create.
Select the container you created, select Upload, browse to the location of the .zip file you created with your project, and then select Upload.
After the upload completes, choose your uploaded blob file, and copy the URL. If you aren't using a managed identity, you might need to generate a SAS URL.
Search for your function app or browse for it in the Function App page.
In your function app, expand Settings, and then select Environment variables.
In the App settings tab, select + Add.
Enter the value WEBSITE_RUN_FROM_PACKAGE
for the Name, and paste the URL of your package in Blob Storage for the Value.
Select Apply, and then select Apply and Confirm to save the setting and restart the function app.
Now you can run your function in Azure to verify that deployment of the deployment package .zip file was successful.
You can configure Azure Blob Storage to authorize requests with Microsoft Entra ID. This configuration means that instead of generating a SAS key with an expiration, you can instead rely on the application's managed identity. By default, the app's system-assigned identity is used. If you wish to specify a user-assigned identity, you can set the WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID
app setting to the resource ID of that identity. The setting can also accept SystemAssigned
as a value, which is equivalent to omitting the setting.
To enable the package to be fetched using the identity:
Ensure that the blob is configured for private access.
Grant the identity the Storage Blob Data Reader role with scope over the package blob. See Assign an Azure role for access to blob data for details on creating the role assignment.
Set the WEBSITE_RUN_FROM_PACKAGE
application setting to the blob URL of the package. This URL is usually of the form https://{storage-account-name}.blob.core.windows.net/{container-name}/{path-to-package}
or similar.
If you wish to specify a user-assigned identity, you can set the WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID
app setting to the resource ID of that identity. The setting can also accept "SystemAssigned" as a value, although this is the same as omitting the setting altogether. A resource ID is a standard representation for a resource in Azure. For a user-assigned managed identity, that is going to be /subscriptions/subid/resourcegroups/rg-name/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name
. The resource ID of a user-assigned managed identity can be obtained in the Settings -> Properties -> ID for the user assigned managed identity.
Hendelser
17. mars, 21 - 21. mars, 10
Bli med i meetup-serien for å bygge skalerbare AI-løsninger basert på virkelige brukstilfeller med andre utviklere og eksperter.
Registrer deg nåOpplæring
Modul
Laste opp bilder til Azure Blob Storage fra en statisk nettapp - Training
Lær hvordan du kan laste opp bilder til Azure Blob Storage fra en statisk nettapp på en sikker måte ved hjelp av en Azure Function for å generere delte tilgangssignaturer ved behov.
Sertifisering
Microsoft Certified: Azure Developer Associate - Certifications
Bygg ende-til-ende-løsninger i Microsoft Azure for å opprette Azure Functions, implementere og administrere nettapper, utvikle løsninger ved hjelp av Azure Storage og mer.