Azure Functions Core Tools çalışınWork with Azure Functions Core Tools
Azure Functions Core Tools, komut isteminden veya terminalden yerel bilgisayarınızda işlevlerinizi geliştirmenize ve test etmenize olanak tanır.Azure Functions Core Tools lets you develop and test your functions on your local computer from the command prompt or terminal. Yerel işlevleriniz canlı Azure hizmetlerine bağlanabilir ve tüm Işlevler çalışma zamanını kullanarak işlevlerinizi yerel bilgisayarınızdaki hata ayıklaması yapabilirsiniz.Your local functions can connect to live Azure services, and you can debug your functions on your local computer using the full Functions runtime. Hatta, Azure aboneliğinize bir işlev uygulaması dağıtabilirsiniz.You can even deploy a function app to your Azure subscription.
Önemli
Yerel geliştirme portalı geliştirme aynı işlev uygulaması ile karıştırmayın.Do not mix local development with portal development in the same function app. Oluşturduğunuzda ve yerel bir projeden işlevleri Yayımlama Portalı'nda proje kodu değiştirmek ve bakımı denemek.When you create and publish functions from a local project, you should not try to maintain or modify project code in the portal.
Yerel bilgisayarınızda işlevleri geliştirme ve temel araçları kullanarak bunları Azure 'da yayımlama aşağıdaki temel adımları izler:Developing functions on your local computer and publishing them to Azure using Core Tools follows these basic steps:
- Çekirdek araçları ve bağımlılıklarını yükler.Install the Core Tools and dependencies.
- Dile özgü şablondan bir işlev uygulama projesi oluşturun.Create a function app project from a language-specific template.
- Tetikleyici ve bağlama uzantılarını kaydedin.Register trigger and binding extensions.
- Depolama ve diğer bağlantıları tanımlayın.Define Storage and other connections.
- Bir tetikleyiciden ve dile özgü şablondan bir işlev oluşturun.Create a function from a trigger and language-specific template.
- İşlevi yerel olarak çalıştırınRun the function locally
- Projeyi Azure 'da yayımlayınPublish the project to Azure
Temel araçlar sürümleriCore Tools versions
Azure Functions Core Tools iki sürümü vardır.There are two versions of Azure Functions Core Tools. Kullandığınız sürüm yerel geliştirme ortamınıza, dil seçimineve gerekli destek düzeyine bağlıdır:The version you use depends on your local development environment, choice of language, and level of support required:
Sürüm 1. x: çalışma zamanının sürüm 1. x ' i destekler.Version 1.x: supports version 1.x of the runtime. Araçların bu sürümü yalnızca Windows bilgisayarlarda desteklenir ve bir NPM paketindenyüklenir.This version of the tools is only supported on Windows computers and is installed from an npm package. Bu sürümle birlikte, resmi olarak desteklenmeyen deneysel dillerde işlevler oluşturabilirsiniz.With this version, you can create functions in experimental languages that are not officially supported. Daha fazla bilgi için bkz. Azure Işlevlerinde desteklenen dillerFor more information, see Supported languages in Azure Functions
Sürüm 2. x: çalışma zamanının sürüm 2. x' i destekler.Version 2.x: supports version 2.x of the runtime. Bu sürüm Windows, MacOSve Linux'u destekler.This version supports Windows, macOS, and Linux. Yükleme için platforma özgü paket yöneticilerini veya NPM 'yi kullanır.Uses platform-specific package managers or npm for installation.
Aksi belirtilmediği takdirde, bu makaledeki örnekler 2. x sürümü içindir.Unless otherwise noted, the examples in this article are for version 2.x.
Azure Functions Core Tools’u YüklemeInstall the Azure Functions Core Tools
Azure Functions Core Tools , yerel geliştirme bilgisayarınızda çalıştırabileceğiniz Azure işlevleri çalışma zamanını destekleyen aynı çalışma zamanının bir sürümünü içerir.Azure Functions Core Tools includes a version of the same runtime that powers Azure Functions runtime that you can run on your local development computer. Ayrıca işlevler oluşturmak, Azure 'a bağlanmak ve işlev projelerini dağıtmak için komutlar sağlar.It also provides commands to create functions, connect to Azure, and deploy function projects.
Sürüm 2. xVersion 2.x
Araçların sürüm 2. x, .NET Core üzerinde oluşturulan Azure Işlevleri çalışma zamanı 2. x 'i kullanır.Version 2.x of the tools uses the Azure Functions runtime 2.x that is built on .NET Core. Bu sürüm, Windows, MacOSve Linuxdahil tüm platformlarda .NET Core 2. x desteği için desteklenir.This version is supported on all platforms .NET Core 2.x supports, including Windows, macOS, and Linux.
Önemli
Uzantı demetikullanarak .NET Core 2. x SDK 'yı yükleme gereksinimini atlayabilirsiniz.You can bypass the requirement for installing the .NET Core 2.x SDK by using extension bundles.
PencerelerinWindows
Aşağıdaki adımlarda, Windows 'a temel araçları yüklemek için NPM kullanılır.The following steps use npm to install Core Tools on Windows. Chocolateyde kullanabilirsiniz.You can also use Chocolatey. Daha fazla bilgi için bkz. temel araçlar Benioku.For more information, see the Core Tools readme.
NPM içeren Node.js' yi yükler.Install Node.js, which includes npm. Araçların sürüm 2. x için yalnızca Node. js 8,5 ve üzeri sürümleri desteklenir.For version 2.x of the tools, only Node.js 8.5 and later versions are supported.
Temel Araçlar paketini yükler:Install the Core Tools package:
npm install -g azure-functions-core-tools
NPM 'nin temel araçlar paketini indirmesi ve yüklemesi birkaç dakika sürebilir.It may take a few minutes for npm to download and install the Core Tools package.
Uzantı demetikullanmayı planlamıyorsanız, Windows için .NET Core 2. x SDK 'sınıyükleyebilirsiniz.If you do not plan to use extension bundles, install the .NET Core 2.x SDK for Windows.
Homebrew ile MacOSMacOS with Homebrew
Aşağıdaki adımlarda, macOS 'a çekirdek araçları yüklemek için homebrew kullanılır.The following steps use Homebrew to install the Core Tools on macOS.
Zaten yüklenmemişse homebrew'ı yükleme.Install Homebrew, if it's not already installed.
Temel Araçlar paketini yükler:Install the Core Tools package:
brew tap azure/functions brew install azure-functions-core-tools
Uzantı demetikullanmayı planlamıyorsanız, MacOS için .NET Core 2. x SDK'yı yükleyebilirsiniz.If you do not plan to use extension bundles, install .NET Core 2.x SDK for macOS.
APT ile Linux (Ubuntu/dekim)Linux (Ubuntu/Debian) with APT
Aşağıdaki adımlarda, Ubuntu/de, Linux dağıtımına çekirdek araçları yüklemek için apt kullanılır.The following steps use APT to install Core Tools on your Ubuntu/Debian Linux distribution. Diğer Linux dağıtımları için bkz. temel araçlar Benioku dosyası.For other Linux distributions, see the Core Tools readme.
Paket bütünlüğünü doğrulamak için Microsoft paket deposu GPG anahtarını yükler:Install the Microsoft package repository GPG key, to validate package integrity:
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
Bir APT güncelleştirmesi yapmadan önce .NET geliştirme kaynak listesini ayarlayın.Set up the .NET development source list before doing an APT update.
Ubuntu için APT kaynak listesini ayarlamak için şu komutu çalıştırın:To set up the APT source list for Ubuntu, run this command:
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'
Dekim için APT kaynak listesini ayarlamak için şu komutu çalıştırın:To set up the APT source list for Debian, run this command:
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list'
Aşağıda listelenen uygun Linux sürümü dizelerinden biri için
/etc/apt/sources.list.d/dotnetdev.list
dosyasını denetleyin:Check the/etc/apt/sources.list.d/dotnetdev.list
file for one of the appropriate Linux version strings listed below:Linux dağıtımıLinux distribution SürümVersion Debian 10Debian 10 buster
Borçlu 9Debian 9 stretch
Desek8Debian 8 jessie
Ubuntu 18,10Ubuntu 18.10 cosmic
Ubuntu 18.04Ubuntu 18.04 bionic
Ubuntu 17,04Ubuntu 17.04 zesty
Ubuntu 16.04/Linux Mint 18Ubuntu 16.04/Linux Mint 18 xenial
APT kaynak güncelleştirmesini başlatın:Start the APT source update:
sudo apt-get update
Temel Araçlar paketini yükler:Install the Core Tools package:
sudo apt-get install azure-functions-core-tools
Uzantı demetikullanmayı planlamıyorsanız, Linux için .NET Core 2. x SDK'yı yükleyebilirsiniz.If you do not plan to use extension bundles, install .NET Core 2.x SDK for Linux.
Yerel Işlevler projesi oluşturmaCreate a local Functions project
Bir işlevler proje dizini, Host. JSON ve Local. Settings. JSONdosyalarını, tek tek işlevlerin kodunu içeren alt klasörlerle birlikte içerir.A functions project directory contains the files host.json and local.settings.json, along with subfolders that contain the code for individual functions. Bu dizin, Azure 'daki bir işlev uygulamasının eşdeğeridir.This directory is the equivalent of a function app in Azure. Işlevler klasör yapısı hakkında daha fazla bilgi edinmek için bkz. Azure işlevleri Geliştirici Kılavuzu.To learn more about the Functions folder structure, see the Azure Functions developers guide.
Sürüm 2. x, başlatıldığında projeniz için varsayılan bir dil seçmenizi ve tüm işlevlerin varsayılan dil şablonlarını kullanmasını gerektirir.Version 2.x requires you to select a default language for your project when it is initialized, and all functions added use default language templates. 1. x sürümünde, her bir işlev oluşturduğunuzda dili belirtirsiniz.In version 1.x, you specify the language each time you create a function.
Terminal penceresinde veya bir komut isteminden, projeyi ve yerel Git deposunu oluşturmak için aşağıdaki komutu çalıştırın:In the terminal window or from a command prompt, run the following command to create the project and local Git repository:
func init MyFunctionProj
Bir proje adı sağladığınızda, bu ada sahip yeni bir klasör oluşturulur ve başlatılır.When you provide a project name, a new folder with that name is created and initialized. Aksi takdirde, geçerli klasör başlatılır.Otherwise, the current folder is initialized.
Sürüm 2. x içinde, komutunu çalıştırdığınızda projeniz için bir çalışma zamanı seçmeniz gerekir.In version 2.x, when you run the command you must choose a runtime for your project.
Select a worker runtime:
dotnet
node
python
powershell
Yukarı/aşağı ok tuşlarını kullanarak bir dil seçin ve ENTER tuşuna basın.Use the up/down arrow keys to choose a language, then press Enter. JavaScript veya TypeScript işlevleri geliştirmeyi planlıyorsanız düğüm' yi seçin ve ardından dili seçin.If you plan to develop JavaScript or TypeScript functions, choose node, and then select the language. TypeScript bazı ek gereksinimleresahiptir.TypeScript has some additional requirements.
Çıktı bir JavaScript projesi için aşağıdaki örneğe benzer şekilde görünür:The output looks like the following example for a JavaScript project:
Select a worker runtime: node
Writing .gitignore
Writing host.json
Writing local.settings.json
Writing C:\myfunctions\myMyFunctionProj\.vscode\extensions.json
Initialized empty Git repository in C:/myfunctions/myMyFunctionProj/.git/
func init
, aksi belirtilmediği takdirde yalnızca sürüm 2. x olan aşağıdaki seçenekleri destekler:func init
supports the following options, which are version 2.x-only, unless otherwise noted:
SeçenekOption | AçıklamaDescription |
---|---|
--csharp --dotnet |
Bir C# sınıf kitaplığı (. cs) projesibaşlatır.Initializes a C# class library (.cs) project. |
--csx |
Bir C# betik (. CSX) projesibaşlatır.Initializes a C# script (.csx) project. Sonraki komutlarda --csx belirtmelisiniz.You must specify --csx in subsequent commands. |
--docker |
Seçilen --worker-runtime temel bir görüntü kullanarak kapsayıcı için bir Dockerfile oluşturun.Create a Dockerfile for a container using a base image that is based on the chosen --worker-runtime . Özel bir Linux kapsayıcısına yayımlamayı planlarken bu seçeneği kullanın.Use this option when you plan to publish to a custom Linux container. |
--docker-only |
Mevcut bir projeye Dockerfile ekler.Adds a Dockerfile to an existing project. Belirtilmemişse veya Local. Settings. JSON içinde ayarlanmamışsa çalışan çalışma zamanı için sorar.Prompts for the worker-runtime if not specified or set in local.settings.json. Mevcut bir projeyi özel bir Linux kapsayıcısına yayımlamayı planlarken bu seçeneği kullanın.Use this option when you plan to publish an existing project to a custom Linux container. |
--force |
Projede var olan dosyalar olduğunda bile projeyi başlatın.Initialize the project even when there are existing files in the project. Bu ayar aynı ada sahip varolan dosyaların üzerine yazar.This setting overwrites existing files with the same name. Proje klasöründeki diğer dosyalar etkilenmez.Other files in the project folder aren't affected. |
--java |
Bir Java projesibaşlatır.Initializes a Java project. |
--javascript --node |
Bir JavaScript projesibaşlatır.Initializes a JavaScript project. |
--no-source-control -n |
1. x sürümünde bir git deposunun varsayılan oluşturulmasını engeller.Prevents the default creation of a Git repository in version 1.x. Sürüm 2. x içinde git deposu varsayılan olarak oluşturulmaz.In version 2.x, the git repository isn't created by default. |
--powershell |
Bir PowerShell projesibaşlatır.Initializes a PowerShell project. |
--python |
Bir Python projesibaşlatır.Initializes a Python project. |
--source-control |
Git deposunun oluşturulup oluşturulmayacağını denetler.Controls whether a git repository is created. Varsayılan olarak, bir depo oluşturulmaz.By default, a repository isn't created. true , bir depo oluşturulur.When true , a repository is created. |
--typescript |
Bir TypeScript projesibaşlatır.Initializes a TypeScript project. |
--worker-runtime |
Projenin dil çalışma zamanını ayarlar.Sets the language runtime for the project. Desteklenen değerler şunlardır: csharp , dotnet , java , javascript ,node (JavaScript), powershell , python ve typescript .Supported values are: csharp , dotnet , java , javascript ,node (JavaScript), powershell , python , and typescript . Ayarlanmaması durumunda, başlatma sırasında çalışma zamanını seçmeniz istenir.When not set, you are prompted to choose your runtime during initialization. |
Önemli
Varsayılan olarak, temel araçların sürüm 2. x 'i, .NET çalışma zamanına yönelik işlev uygulaması projelerini C# sınıf projeleri (. csproj) olarak oluşturur.By default, version 2.x of the Core Tools creates function app projects for the .NET runtime as C# class projects (.csproj). Visual C# Studio veya Visual Studio Code ile kullanılabilen bu projeler, test sırasında ve Azure 'a yayımlarken derlenir.These C# projects, which can be used with Visual Studio or Visual Studio Code, are compiled during testing and when publishing to Azure. Bunun yerine, 1. x sürümünde oluşturulan aynı C# komut dosyası (. CSX) dosyalarını oluşturmak ve bunlarla çalışmak istiyorsanız, işlevleri oluştururken ve dağıtırken --csx
parametresini eklemeniz gerekir.If you instead want to create and work with the same C# script (.csx) files created in version 1.x and in the portal, you must include the --csx
parameter when you create and deploy functions.
Uzantılarını kaydetmeRegister extensions
Bağlamaları hariç olmak üzere HTTP ve Zamanlayıcı Tetikleyicileri, İşlevler çalışma zamanı sürüm 2.x uzantı paketleri uygulanır.With the exception of HTTP and timer triggers, Functions bindings in runtime version 2.x are implemented as extension packages. Sürüm 2.x Azure işlevleri çalışma zamanı, sahip, işlevlerde kullanılan bağlama türleri için uzantıları açıkça kaydedilecek.In version 2.x of the Azure Functions runtime, you have to explicitly register the extensions for the binding types used in your functions. Bu HTTP bağlamaları ve uzantılar gerektirmeyen Zamanlayıcı Tetikleyicileri özel durumlardır.The exceptions to this are HTTP bindings and timer triggers, which do not require extensions.
Bağlama uzantıları'nı tek başına yüklemeyi seçebilirsiniz veya bir uzantı paketi başvurusu host.json proje dosyasına ekleyebilirsiniz.You can choose to install binding extensions individually, or you can add an extension bundle reference to the host.json project file. Uzantı paketleri birden çok bağlama türleri kullanırken paket uyumluluk sorunlarına sahip olma olasılığını kaldırır.Extension bundles removes the chance of having package compatibility issues when using multiple binding types. Bağlama uzantılarını kaydetme için önerilen yaklaşımdır.It is the recommended approach for registering binding extensions. Uzantı paketleri de .NET Core yükleme gereksinimini kaldırır 2.x SDK.Extension bundles also removes the requirement of installing the .NET Core 2.x SDK.
Uzantı paketleriExtension bundles
Bağlama uzantılarını yüklemenin en kolay yolu, uzantıpaketlerinin etkinleştirilme yöntemidir.The easiest way to install binding extensions is to enable extension bundles. Paketleri etkinleştirdiğinizde, önceden tanımlanmış bir uzantı paketleri kümesi otomatik olarak yüklenir.When you enable bundles, a predefined set of extension packages is automatically installed.
Uzantı paketleri 'ni etkinleştirmek için, Host. json dosyasını açın ve içeriğini aşağıdaki kodla eşleşecek şekilde güncelleştirin:To enable extension bundles, open the host.json file and update its contents to match the following code:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
Daha fazla bilgi için bkz. kaydetme Azure işlevleri bağlama uzantıları.To learn more, see Register Azure Functions binding extensions. Bağlamaları functions.json dosyaya eklemeden önce uzantı paketleri için host.json eklemeniz gerekir.You should add extension bundles to the host.json before you add bindings to the functions.json file.
Tek tek uzantılarını kaydetmeRegister individual extensions
Bir paket halinde olmayan uzantıları yüklemeniz gerekiyorsa, özel bağlamalar için ayrı bir uzantı paketleri el ile kaydedebilirsiniz.If you need to install extensions that aren't in a bundle, you can manually register individual extension packages for specific bindings.
Not
El ile uzantıları kullanarak kaydetmek için func extensions install
, .NET Core olmalıdır 2.x SDK'sı yüklü.To manually register extensions by using func extensions install
, you must have the .NET Core 2.x SDK installed.
Güncelleştirdikten sonra function.json dosyasını proje klasöründe aşağıdaki komutu çalıştırın, işlevinizi gereken tüm bağlamaları içerecek şekilde.After you have updated your function.json file to include all the bindings that your function needs, run the following command in the project folder.
func extensions install
Komut okur function.json ihtiyacınız paketler görmek için bir dosya yükler ve uzantıları projesi oluşturur.The command reads the function.json file to see which packages you need, installs them, and rebuilds the extensions project. Geçerli sürümde yeni bağlamalar ekler, ancak var olan bağlamaları güncelleştirmez.It adds any new bindings at the current version but does not update existing bindings. Kullanım --force
yenilerini yüklerken mevcut bağlamaları en son sürüme güncelleştirmek için seçeneği.Use the --force
option to update existing bindings to the latest version when installing new ones.
Yerel ayarlar dosyasıLocal settings file
Local. Settings. JSON dosyası, uygulama ayarlarını, bağlantı dizelerini ve yerel geliştirme araçları tarafından kullanılan ayarları depolar.The local.settings.json file stores app settings, connection strings, and settings used by local development tools. Local. Settings. JSON dosyasındaki ayarlar yalnızca projeleri yerel olarak çalıştırırken kullanılır.Settings in the local.settings.json file are used only when you're running projects locally. Yerel ayarlar dosyası bu yapıya sahiptir:The local settings file has this structure:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "<language worker>",
"AzureWebJobsStorage": "<connection-string>",
"AzureWebJobsDashboard": "<connection-string>",
"MyBindingConnection": "<binding-connection-string>"
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*",
"CORSCredentials": false
},
"ConnectionStrings": {
"SQLConnectionString": "<sqlclient-connection-string>"
}
}
Projeleri yerel olarak çalıştırdığınızda bu ayarlar desteklenir:These settings are supported when you run projects locally:
AyarSetting | AçıklamaDescription |
---|---|
IsEncrypted |
Bu ayar olarak true ayarlandığında, tüm değerler yerel makine anahtarıyla şifrelenir.When this setting is set to true , all values are encrypted with a local machine key. Komutlarıyla birlikte func settings kullanılır.Used with func settings commands. Varsayılan değer false .Default value is false . |
Values |
Bir proje yerel olarak çalışırken kullanılan uygulama ayarları ve bağlantı dizeleri dizisi.Array of application settings and connection strings used when a project is running locally. Bu anahtar-değer (dize-dize) çiftleri, gibi AzureWebJobsStorage Azure 'daki işlev uygulamanızda uygulama ayarlarına karşılık gelir.These key-value (string-string) pairs correspond to application settings in your function app in Azure, like AzureWebJobsStorage . Birçok tetikleyici ve bağlamanın, Connection BLOB depolama tetikleyicisigibi bir bağlantı dizesi uygulama ayarına başvuran bir özelliği vardır.Many triggers and bindings have a property that refers to a connection string app setting, like Connection for the Blob storage trigger. Bu özellikler için Values dizide tanımlanmış bir uygulama ayarı gereklidir.For these properties, you need an application setting defined in the Values array. AzureWebJobsStorage , HTTP dışındaki Tetikleyiciler için gerekli bir uygulama ayarıdır.AzureWebJobsStorage is a required app setting for triggers other than HTTP. İşlevler çalışma zamanının 2. x sürümü, temel araçlar tarafından FUNCTIONS_WORKER_RUNTIME projeniz için oluşturulan [] ayarını gerektirir.Version 2.x of the Functions runtime requires the [FUNCTIONS_WORKER_RUNTIME ] setting, which is generated for your project by Core Tools. Azure Storage öykünücüsü yerel olarak yüklüyse ve olarak AzureWebJobsStorage UseDevelopmentStorage=true ayarlarsanız, çekirdek araçlar öykünücüyü kullanır.When you have the Azure storage emulator installed locally and you set AzureWebJobsStorage to UseDevelopmentStorage=true , Core Tools uses the emulator. Öykünücü geliştirme sırasında faydalıdır, ancak dağıtımdan önce gerçek bir depolama bağlantısı ile test etmeniz gerekir.The emulator is useful during development, but you should test with an actual storage connection before deployment.Değerler dize olmalıdır ve JSON nesneleri veya dizileri olmamalıdır.Values must be strings and not JSON objects or arrays. Ayar adları iki nokta ( : ) veya çift alt çizgi (__ ) içeremez.Setting names can't include a colon (: ) or a double underline (__ ). Bu karakterler çalışma zamanı tarafından ayrılmıştır.These characters are reserved by the runtime. |
Host |
Bu bölümdeki ayarlar, projeleri yerel olarak çalıştırdığınızda Işlevler ana bilgisayar işlemini özelleştirir.Settings in this section customize the Functions host process when you run projects locally. Bu ayarlar, Azure 'da projeler çalıştırdığınızda da uygulanan Host. JSON ayarlarından ayrıdır.These settings are separate from the host.json settings, which also apply when you run projects in Azure. |
LocalHttpPort |
Yerel işlevler Konağı (func host start ve func run ) çalıştırılırken kullanılan varsayılan bağlantı noktasını ayarlar.Sets the default port used when running the local Functions host (func host start and func run ). --port Komut satırı seçeneği bu ayarın üzerine gelir.The --port command-line option takes precedence over this setting. |
CORS |
, Çıkış noktaları arası kaynak paylaşımı (CORS)için izin verilen kaynakları tanımlar.Defines the origins allowed for cross-origin resource sharing (CORS). Kaynaklar, boşluk olmadan virgülle ayrılmış bir liste olarak sağlanır.Origins are supplied as a comma-separated list with no spaces. (*) Joker değeri desteklenir ve bu, herhangi bir kaynaktan gelen isteklere izin verir.The wildcard value (*) is supported, which allows requests from any origin. |
CORSCredentials |
Olarak true ayarlandığında, isteklere izin withCredentials verir.When set to true , allows withCredentials requests. |
ConnectionStrings |
Bir koleksiyon.A collection. İşlev bağlamalarınız tarafından kullanılan bağlantı dizeleri için bu koleksiyonu kullanmayın.Don't use this collection for the connection strings used by your function bindings. Bu koleksiyon, genellikle ConnectionStrings Entity Frameworkgibi bir yapılandırma dosyasının bölümünden bağlantı dizelerini alan çerçeveler tarafından kullanılır.This collection is used only by frameworks that typically get connection strings from the ConnectionStrings section of a configuration file, like Entity Framework. Bu nesnedeki bağlantı dizeleri System. Data. SqlClientsağlayıcı türüyle ortama eklenir.Connection strings in this object are added to the environment with the provider type of System.Data.SqlClient. Bu koleksiyondaki öğeler, diğer uygulama ayarlarıyla Azure 'da yayımlanmaz.Items in this collection aren't published to Azure with other app settings. Bu değerleri Connection strings , işlev uygulaması ayarlarınızın koleksiyonuna açıkça eklemeniz gerekir.You must explicitly add these values to the Connection strings collection of your function app settings. İşlev kodunuzda bir SqlConnection oluşturuyorsanız, bağlantı dizesi değerini portaldaki uygulama ayarları ' nda diğer bağlantılarınız ile depolamanız gerekir.If you're creating a SqlConnection in your function code, you should store the connection string value with your other connections in Application Settings in the portal. |
Varsayılan olarak, bu ayarlar proje Azure 'da yayımlandığında otomatik olarak geçirilmez.By default, these settings are not migrated automatically when the project is published to Azure. Bu ayarların Azure 'daki işlev uygulamasına eklendiğinden emin olmak için yayımlarken --publish-local-settings
anahtarını kullanın.Use the --publish-local-settings
switch when you publish to make sure these settings are added to the function app in Azure. ConnectionString içindeki değerlerin hiçbir şekilde yayımlanmadığını unutmayın.Note that values in ConnectionStrings are never published.
İşlev uygulaması ayarları değerleri, kodunuzda ortam değişkenleri olarak da okunabilir.The function app settings values can also be read in your code as environment variables. Daha fazla bilgi için, bu dile özgü başvuru konularının ortam değişkenleri bölümüne bakın:For more information, see the Environment variables section of these language-specific reference topics:
AzureWebJobsStorage
için geçerli bir depolama bağlantı dizesi ayarlanmamışsa ve öykünücü kullanılmıyorsa, aşağıdaki hata iletisi görüntülenir:When no valid storage connection string is set for AzureWebJobsStorage
and the emulator isn't being used, the following error message is shown:
Yerel. Settings. JSON içinde AzureWebJobsStorage için eksik değer.Missing value for AzureWebJobsStorage in local.settings.json. HTTP dışındaki tüm tetikleyiciler için bu gereklidir.This is required for all triggers other than HTTP. ' Func Azure functionapp Fetch-App-settings <functionAppName>' çalıştırabilir veya yerel. Settings. JSON içinde bir bağlantı dizesi belirtebilirsiniz.You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json.
Depolama bağlantı dizelerinizi alınGet your storage connection strings
Geliştirme için depolama öykünücüsü kullanılırken bile gerçek bir depolama bağlantısıyla test etmek isteyebilirsiniz.Even when using the storage emulator for development, you may want to test with an actual storage connection. Zaten bir depolama hesabı oluşturmuşolduğunuz varsayılarak, aşağıdaki yollarla geçerli bir depolama bağlantı dizesi alabilirsiniz:Assuming you have already created a storage account, you can get a valid storage connection string in one of the following ways:
Azure portalda, depolama hesaplarınıarayıp seçin.From the Azure portal, search for and select Storage accounts. Azure portal
Depolama hesabınızı seçin, Ayarlar' da erişim tuşları ' nı seçin, sonra bağlantı dizesi değerlerinden birini kopyalayın.Select your storage account, select Access keys in Settings, then copy one of the Connection string values. Azure portal](./media/functions-run-local/copy-storage-connection-portal.png) bağlantı dizesini ![Kopyala
Azure hesabınıza bağlanmak için Azure Depolama Gezgini kullanın.Use Azure Storage Explorer to connect to your Azure account. Gezgin'de aboneliğinizi genişletin, depolama hesabınızı seçin ve birincil veya ikincil bağlantı dizesini kopyalayın.In the Explorer, expand your subscription, select your storage account, and copy the primary or secondary connection string.
Azure 'dan bağlantı dizesini aşağıdaki komutlardan biriyle indirmek için temel araçları kullanın:Use Core Tools to download the connection string from Azure with one of the following commands:
Var olan bir işlev uygulamasından tüm ayarları indir:Download all settings from an existing function app:
func azure functionapp fetch-app-settings <FunctionAppName>
Belirli bir depolama hesabı için bağlantı dizesini al:Get the Connection string for a specific storage account:
func azure storage fetch-connection-string <StorageAccountName>
Azure 'da henüz oturum açmadıysanız, bunu yapmanız istenir.When you are not already signed in to Azure, you are prompted to do so.
İşlev oluşturmaCreate a function
Bir işlev oluşturmak için aşağıdaki komutu çalıştırın:To create a function, run the following command:
func new
Sürüm 2. x ' de func new
çalıştırdığınızda, işlev uygulamanızın varsayılan dilinde bir şablon seçmeniz istenir. Ayrıca, işleviniz için bir ad seçmeniz istenir.In version 2.x, when you run func new
you are prompted to choose a template in the default language of your function app, then you are also prompted to choose a name for your function. 1. x sürümünde de dili seçmeniz istenir.In version 1.x, you are also prompted to choose the language.
Select a language: Select a template:
Blob trigger
Cosmos DB trigger
Event Grid trigger
HTTP trigger
Queue trigger
SendGrid
Service Bus Queue trigger
Service Bus Topic trigger
Timer trigger
İşlev kodu, aşağıdaki kuyruk tetikleyicisi çıktısında görebileceğiniz gibi, belirtilen işlev adına sahip bir alt klasörde oluşturulur:Function code is generated in a subfolder with the provided function name, as you can see in the following queue trigger output:
Select a language: Select a template: Queue trigger
Function name: [QueueTriggerJS] MyQueueTrigger
Writing C:\myfunctions\myMyFunctionProj\MyQueueTrigger\index.js
Writing C:\myfunctions\myMyFunctionProj\MyQueueTrigger\readme.md
Writing C:\myfunctions\myMyFunctionProj\MyQueueTrigger\sample.dat
Writing C:\myfunctions\myMyFunctionProj\MyQueueTrigger\function.json
Ayrıca, aşağıdaki bağımsız değişkenleri kullanarak komutta bu seçenekleri belirtebilirsiniz:You can also specify these options in the command using the following arguments:
Bağımsız DeğişkenArgument | AçıklamaDescription |
---|---|
--csx |
(Sürüm 2. x) 1. x C# sürümünde ve portalda kullanılan aynı komut dosyası (. CSX) şablonlarını üretir.(Version 2.x) Generates the same C# script (.csx) templates used in version 1.x and in the portal. |
--language -l |
,, Veya JavaScript gibi şablon programlama C#dili F#.The template programming language, such as C#, F#, or JavaScript. Bu seçenek, 1. x sürümünde gereklidir.This option is required in version 1.x. Sürüm 2. x içinde bu seçeneği kullanmayın veya çalışan çalışma zamanıyla eşleşen bir dil seçin.In version 2.x, do not use this option or choose a language that matches the worker runtime. |
--name -n |
İşlev adı.The function name. |
--template -t |
Desteklenen her dil için kullanılabilir şablonların tüm listesini görmek için func templates list komutunu kullanın.Use the func templates list command to see the complete list of available templates for each supported language. |
Örneğin, tek bir komutta bir JavaScript HTTP tetikleyicisi oluşturmak için şunu çalıştırın:For example, to create a JavaScript HTTP trigger in a single command, run:
func new --template "Http Trigger" --name MyHttpTrigger
Tek bir komutta kuyruk tetiklemeli bir işlev oluşturmak için şunu çalıştırın:To create a queue-triggered function in a single command, run:
func new --template "Queue Trigger" --name QueueTriggerJS
İşlevleri yerel olarak çalıştırRun functions locally
Bir Işlevler projesi çalıştırmak için, Işlevler ana bilgisayarını çalıştırın.To run a Functions project, run the Functions host. Konak, projedeki tüm işlevler için Tetikleyicileri mümkün.The host enables triggers for all functions in the project.
Sürüm 2. xVersion 2.x
Çalışma zamanının 2. x sürümünde, başlangıç komutu Proje dilinize bağlı olarak değişir.In version 2.x of the runtime, the start command varies, depending on your project language.
C#C#
func start --build
JavaScriptJavaScript
func start
TypeScriptTypeScript
npm install
npm start
Sürüm 1. xVersion 1.x
Işlevler çalışma zamanının sürüm 1. x, aşağıdaki örnekte olduğu gibi host
komutunu gerektirir:Version 1.x of the Functions runtime requires the host
command, as in the following example:
func host start
func start
aşağıdaki seçenekleri destekler:func start
supports the following options:
SeçenekOption | AçıklamaDescription |
---|---|
--no-build |
Çalıştırmadan önce derleme geçerli projesi yok.Do no build current project before running. Yalnızca DotNet projeleri için.For dotnet projects only. Varsayılan değer false olarak ayarlanmıştır.Default is set to false. Yalnızca sürüm 2. x.Version 2.x only. |
--cert |
Özel anahtar içeren bir. pfx dosyasının yolu.The path to a .pfx file that contains a private key. Yalnızca --useHttps ile kullanılır.Only used with --useHttps . Yalnızca sürüm 2. x.Version 2.x only. |
--cors-credentials |
Yalnızca çıkış noktaları arası kimlik doğrulamalı isteklere (yani, tanımlama bilgileri ve kimlik doğrulama üstbilgisi) sürüm 2. x 'e izin verin.Allow cross-origin authenticated requests (i.e. cookies and the Authentication header) Version 2.x only. |
--cors |
CORS kaynakları için boşluk olmadan virgülle ayrılmış bir liste.A comma-separated list of CORS origins, with no spaces. |
--language-worker |
Dil çalışanını yapılandırmak için bağımsız değişkenler.Arguments to configure the language worker. Yalnızca sürüm 2. x.Version 2.x only. |
--nodeDebugPort -n |
Kullanılacak düğüm hata ayıklayıcı bağlantı noktası.The port for the node debugger to use. Varsayılan: Launch. JSON veya 5858 değeri.Default: A value from launch.json or 5858. Yalnızca sürüm 1. x.Version 1.x only. |
--password |
Bir. pfx dosyasının parolasını içeren parola veya dosya.Either the password or a file that contains the password for a .pfx file. Yalnızca --cert ile kullanılır.Only used with --cert . Yalnızca sürüm 2. x.Version 2.x only. |
--port -p |
Dinlenecek yerel bağlantı noktası.The local port to listen on. Varsayılan değer: 7071.Default value: 7071. |
--pause-on-error |
İşlemden çıkmadan önce ek giriş için duraklatın.Pause for additional input before exiting the process. Yalnızca tümleşik geliştirme ortamından (IDE) temel araçlar başlatılırken kullanılır.Used only when launching Core Tools from an integrated development environment (IDE). |
--script-root --prefix |
Çalıştırılacak veya dağıtılacak işlev uygulamasının köküne ait yolu belirtmek için kullanılır.Used to specify the path to the root of the function app that is to be run or deployed. Bu, bir alt klasöre proje dosyaları üreten derlenmiş projeler için kullanılır.This is used for compiled projects that generate project files into a subfolder. Örneğin, bir C# sınıf kitaplığı projesi oluşturduğunuzda, Host. JSON, Local. Settings. JSON ve function. json dosyaları MyProject/bin/Debug/netstandard2.0 gibi bir yol içeren bir kök alt klasörde oluşturulur.For example, when you build a C# class library project, the host.json, local.settings.json, and function.json files are generated in a root subfolder with a path like MyProject/bin/Debug/netstandard2.0 . Bu durumda, ön eki --script-root MyProject/bin/Debug/netstandard2.0 olarak ayarlayın.In this case, set the prefix as --script-root MyProject/bin/Debug/netstandard2.0 . Bu, Azure 'da çalışırken işlev uygulamasının köküdür.This is the root of the function app when running in Azure. |
--timeout -t |
Işlevlerin başlaması için gereken zaman aşımı (saniye cinsinden).The timeout for the Functions host to start, in seconds. Varsayılan: 20 saniye.Default: 20 seconds. |
--useHttps |
http://localhost:{port} yerine https://localhost:{port} bağlayın.Bind to https://localhost:{port} rather than to http://localhost:{port} . Varsayılan olarak, bu seçenek bilgisayarınızda güvenilir bir sertifika oluşturur.By default, this option creates a trusted certificate on your computer. |
Işlevler ana bilgisayarı başlatıldığında, HTTP ile tetiklenen işlevlerin URL 'sini verir:When the Functions host starts, it outputs the URL of HTTP-triggered functions:
Found the following functions:
Host.Functions.MyHttpTrigger
Job host started
Http Function MyHttpTrigger: http://localhost:7071/api/MyHttpTrigger
Önemli
Yerel olarak çalışırken, HTTP uç noktaları için kimlik doğrulama zorlanmaz.When running locally, authentication isn't enforced for HTTP endpoints. Bu, tüm yerel HTTP isteklerinin authLevel = "anonymous"
olarak işlendiği anlamına gelir.This means that all local HTTP requests are handled as authLevel = "anonymous"
. Daha fazla bilgi için bkz. http bağlama makalesi.For more information, see the HTTP binding article.
Test verilerini bir işleve geçirmePassing test data to a function
İşlevlerinizi yerel olarak test etmek için, işlevleri ana bilgisayarı başlatır ve http isteklerini kullanarak yerel sunucuda uç noktaları çağırabilirsiniz.To test your functions locally, you start the Functions host and call endpoints on the local server using HTTP requests. Çağırdığınız uç nokta, işlevin türüne bağlıdır.The endpoint you call depends on the type of function.
Not
Bu konudaki örnekler, Terminal veya komut isteminden HTTP istekleri göndermek için kıvrımlı aracı kullanır.Examples in this topic use the cURL tool to send HTTP requests from the terminal or a command prompt. Yerel sunucuya HTTP istekleri göndermek için tercih ettiğiniz bir aracı kullanabilirsiniz.You can use a tool of your choice to send HTTP requests to the local server. , Linux tabanlı sistemlerde ve Windows 10 derleme 17063 ve sonraki sürümlerde kıvrımlı aracı varsayılan olarak kullanılabilir.The cURL tool is available by default on Linux-based systems and Windows 10 build 17063 and later. Daha eski Windows 'ta, önce kıvrımlı aracınıindirip yüklemeniz gerekir.On older Windows, you must first download and install the cURL tool.
Test işlevleri hakkında daha fazla genel bilgi için bkz. Azure işlevlerinde kodunuzu test etme stratejileri.For more general information on testing functions, see Strategies for testing your code in Azure Functions.
HTTP ve Web kancası tarafından tetiklenen işlevlerHTTP and webhook triggered functions
HTTP ve Web kancası tarafından tetiklenen işlevleri yerel olarak çalıştırmak için aşağıdaki uç noktayı çağırın:You call the following endpoint to locally run HTTP and webhook triggered functions:
http://localhost:{port}/api/{function_name}
Işlevlerin barındırın dinlediği sunucu adını ve bağlantı noktasını kullandığınızdan emin olun.Make sure to use the same server name and port that the Functions host is listening on. Bunu, Işlev Konağı başlatılırken oluşturulan çıktıda görürsünüz.You see this in the output generated when starting the Function host. Tetikleyici tarafından desteklenen herhangi bir HTTP yöntemini kullanarak bu URL 'YI çağırabilirsiniz.You can call this URL using any HTTP method supported by the trigger.
Aşağıdaki kıvrımlı komutu, sorgu dizesinde geçirilen Name parametresine sahıp bir GET isteğinden MyHttpTrigger
hızlı başlangıç işlevini tetikler.The following cURL command triggers the MyHttpTrigger
quickstart function from a GET request with the name parameter passed in the query string.
curl --get http://localhost:7071/api/MyHttpTrigger?name=Azure%20Rocks
Aşağıdaki örnek, istek gövdesinde bir POST isteği geçirme adından çağrılan aynı fonksiyondır:The following example is the same function called from a POST request passing name in the request body:
curl --request POST http://localhost:7071/api/MyHttpTrigger --data '{"name":"Azure Rocks"}'
Sorgu dizesindeki verileri geçirerek tarayıcıdan GET istekleri yapabilirsiniz.You can make GET requests from a browser passing data in the query string. Diğer tüm HTTP yöntemleri için kıvrımlı, Fiddler, Postman veya benzer bir HTTP test aracı kullanmanız gerekir.For all other HTTP methods, you must use cURL, Fiddler, Postman, or a similar HTTP testing tool.
HTTP dışı tetiklenen işlevlerNon-HTTP triggered functions
HTTP Tetikleyicileri ve Web kancaları dışındaki tüm işlev türlerinde, bir yönetim uç noktası çağırarak işlevlerinizi yerel olarak test edebilirsiniz.For all kinds of functions other than HTTP triggers and webhooks, you can test your functions locally by calling an administration endpoint. Bu uç noktanın yerel sunucuda bir HTTP POST isteğiyle çağrılması işlevi tetikler.Calling this endpoint with an HTTP POST request on the local server triggers the function. İsteğe bağlı olarak, POST isteğinin gövdesinde test verilerini yürütmeye geçirebilirsiniz.You can optionally pass test data to the execution in the body of the POST request. Bu işlev, Azure portal Test sekmesine benzerdir.This functionality is similar to the Test tab in the Azure portal.
HTTP olmayan işlevleri tetiklemek için aşağıdaki yönetici uç noktasını çağırın:You call the following administrator endpoint to trigger non-HTTP functions:
http://localhost:{port}/admin/functions/{function_name}
Test verilerini bir işlevin yönetici uç noktasına geçirmek için, verileri bir POST isteği iletisinin gövdesinde belirtmeniz gerekir.To pass test data to the administrator endpoint of a function, you must supply the data in the body of a POST request message. İleti gövdesinin aşağıdaki JSON biçimine sahip olması gerekir:The message body is required to have the following JSON format:
{
"input": "<trigger_input>"
}
<trigger_input>
değeri, işlevi tarafından beklenen bir biçimde veriler içeriyor.The <trigger_input>
value contains data in a format expected by the function. Aşağıdaki kıvrımlı örnek bir QueueTriggerJS
işlevinin GÖNDERISINI sağlar.The following cURL example is a POST to a QueueTriggerJS
function. Bu durumda, giriş sırada bulunması beklenen iletiyle eşdeğer bir dizedir.In this case, the input is a string that is equivalent to the message expected to be found in the queue.
curl --request POST -H "Content-Type:application/json" --data '{"input":"sample queue data"}' http://localhost:7071/admin/functions/QueueTriggerJS
1. x sürümünde func run
komutu kullanmaUsing the func run
command in version 1.x
Önemli
func run
komutu, araçların 2. x sürümünde desteklenmez.The func run
command is not supported in version 2.x of the tools. Daha fazla bilgi için bkz. Azure işlevleri çalışma zamanı sürümlerini hedeflemekonusu.For more information, see the topic How to target Azure Functions runtime versions.
Ayrıca, func run <FunctionName>
kullanarak doğrudan bir işlevi çağırabilir ve işlev için giriş verileri sağlayabilirsiniz.You can also invoke a function directly by using func run <FunctionName>
and provide input data for the function. Bu komut, Azure portal Test sekmesini kullanarak bir işlevi çalıştırmaya benzer.This command is similar to running a function using the Test tab in the Azure portal.
func run
aşağıdaki seçenekleri destekler:func run
supports the following options:
SeçenekOption | AçıklamaDescription |
---|---|
--content -c |
Satır içi içerik.Inline content. |
--debug -d |
İşlevi çalıştırmadan önce konak işlemine bir hata ayıklayıcı ekleyin.Attach a debugger to the host process before running the function. |
--timeout -t |
Yerel Işlevlerin barındırmaya hazırlanana kadar beklenecek süre (saniye cinsinden).Time to wait (in seconds) until the local Functions host is ready. |
--file -f |
İçerik olarak kullanılacak dosya adı.The file name to use as content. |
--no-interactive |
Girişi istemez.Does not prompt for input. Otomasyon senaryoları için faydalıdır.Useful for automation scenarios. |
Örneğin, HTTP ile tetiklenen bir işlev çağırmak ve içerik gövdesini geçirmek için aşağıdaki komutu çalıştırın:For example, to call an HTTP-triggered function and pass content body, run the following command:
func run MyHttpTrigger -c '{\"name\": \"Azure\"}'
Azure 'da yayımlamaPublish to Azure
Azure Functions Core Tools iki tür dağıtımı destekler: işlev projesi dosyalarını ZIP dağıtımı ve dağıtımaracılığıyla doğrudan işlev uygulamanıza dağıtma.The Azure Functions Core Tools supports two types of deployment: deploying function project files directly to your function app via Zip Deploy and deploying a custom Docker container. Kodunuzu dağıtacağınız Azure aboneliğinizde zaten bir işlev uygulaması oluşturmuşolmanız gerekir.You must have already created a function app in your Azure subscription, to which you'll deploy your code. İkililerin dağıtılması için derleme gerektiren projeler oluşturulmalıdır.Projects that require compilation should be built so that the binaries can be deployed.
Proje klasörü, yayınlanmaması gereken dile özgü dosyalar ve dizinler içerebilir.A project folder may contain language-specific files and directories that shouldn't be published. Dışlanan öğeler kök proje klasöründeki bir. funcignore dosyasında listelenir.Excluded items are listed in a .funcignore file in the root project folder.
Dağıtım (proje dosyaları)Deployment (project files)
Yerel kodunuzu Azure 'da bir işlev uygulamasına yayımlamak için publish
komutunu kullanın:To publish your local code to a function app in Azure, use the publish
command:
func azure functionapp publish <FunctionAppName>
Bu komut, Azure 'da var olan bir işlev uygulamasına yayınlar.This command publishes to an existing function app in Azure. Aboneliğinizde mevcut olmayan bir <FunctionAppName>
yayımlamaya çalışırsanız hata alırsınız.You'll get an error if you try to publish to a <FunctionAppName>
that doesn't exist in your subscription. Azure CLı kullanarak komut isteminden veya Terminal penceresinde bir işlev uygulaması oluşturmayı öğrenmek için bkz. sunucusuz yürütme için işlev uygulaması oluşturma.To learn how to create a function app from the command prompt or terminal window using the Azure CLI, see Create a Function App for serverless execution. Varsayılan olarak, bu komut, uzak derlemeyi kullanır ve uygulamanızı dağıtım paketinden çalıştırmaküzere dağıtır.By default, this command uses remote build and deploys your app to run from the deployment package. Bu önerilen dağıtım modunu devre dışı bırakmak için --nozip
seçeneğini kullanın.To disable this recommended deployment mode, use the --nozip
option.
Önemli
Azure portal bir işlev uygulaması oluşturduğunuzda, varsayılan olarak Işlev çalışma zamanının 2. x sürümünü kullanır.When you create a function app in the Azure portal, it uses version 2.x of the Function runtime by default. İşlev uygulamasının çalışma zamanının sürüm 1. x ' i kullanmasını sağlamak için Sürüm 1. x üzerinde Çalıştır' daki yönergeleri izleyin.To make the function app use version 1.x of the runtime, follow the instructions in Run on version 1.x. Mevcut işlevlere sahip bir işlev uygulamasının çalışma zamanı sürümünü değiştiremezsiniz.You can't change the runtime version for a function app that has existing functions.
Aşağıdaki yayımlama seçenekleri, 1. x ve 2. x sürümleri için geçerlidir:The following publish options apply for both versions, 1.x and 2.x:
SeçenekOption | AçıklamaDescription |
---|---|
--publish-local-settings -i |
Ayarları yerel. Settings. json ' da Azure 'a yayımlayın, bu ayar zaten varsa üzerine yazma isteminde bulunur.Publish settings in local.settings.json to Azure, prompting to overwrite if the setting already exists. Depolama öykünücüsünü kullanıyorsanız, önce uygulama ayarını gerçek bir depolama bağlantısıolarak değiştirin.If you are using the storage emulator, first change the app setting to an actual storage connection. |
--overwrite-settings -y |
--publish-local-settings -i kullanıldığında uygulama ayarlarının üzerine yazma istemi 'ni gizleyin.Suppress the prompt to overwrite app settings when --publish-local-settings -i is used. |
Aşağıdaki yayımlama seçenekleri yalnızca sürüm 2. x içinde desteklenir:The following publish options are only supported in version 2.x:
SeçenekOption | AçıklamaDescription |
---|---|
--publish-settings-only -o |
Yalnızca ayarları yayımlayın ve içeriği atlayın.Only publish settings and skip the content. Varsayılan istem.Default is prompt. |
--list-ignored-files |
Yayımlama sırasında yoksayılan,. funcignore dosyasını temel alan dosyaların listesini görüntüler.Displays a list of files that are ignored during publishing, which is based on the .funcignore file. |
--list-included-files |
Yayımlanan dosyaların bir listesini görüntüler, bu,. funcignore dosyasını temel alır.Displays a list of files that are published, which is based on the .funcignore file. |
--nozip |
Varsayılan Run-From-Package modunu kapatır.Turns the default Run-From-Package mode off. |
--build-native-deps |
Python işlev uygulamaları yayımlanırken. tekerlek klasörü oluşturmayı atlar.Skips generating .wheels folder when publishing python function apps. |
--build -b |
Bir Linux işlev uygulamasına dağıtım yaparken derleme eylemi gerçekleştirir.Performs build action when deploying to a Linux function app. Kabul eder: remote ve local .Accepts: remote and local . |
--additional-packages |
Yerel bağımlılıklar oluşturulurken yüklenecek paketlerin listesi.List of packages to install when building native dependencies. Örneğin: python3-dev libevent-dev .For example: python3-dev libevent-dev . |
--force |
Belirli senaryolarda yayımlama öncesi doğrulamayı yoksayın.Ignore pre-publishing verification in certain scenarios. |
--csx |
Bir C# betik (. CSX) projesi yayımlayın.Publish a C# script (.csx) project. |
--no-build |
.NET sınıf kitaplığı işlevleri oluşturmayın.Don't build .NET class library functions. |
--dotnet-cli-params |
Derlenen C# (. csproj) işlevleri yayımlandığında, temel Araçlar ' DotNet Build--output bin/Publish ' yöntemini çağırır.When publishing compiled C# (.csproj) functions, the core tools calls 'dotnet build --output bin/publish'. Buna geçirilen parametreler komut satırına eklenecektir.Any parameters passed to this will be appended to the command line. |
Dağıtım (özel kapsayıcı)Deployment (custom container)
Azure Işlevleri, işlev projenizi özel bir Docker kapsayıcısınadağıtmanızı sağlar.Azure Functions lets you deploy your function project in a custom Docker container. Daha fazla bilgi için bkz. özel bir görüntü kullanarak Linux 'ta Işlev oluşturma.For more information, see Create a function on Linux using a custom image. Özel kapsayıcılar bir Dockerfile içermelidir.Custom containers must have a Dockerfile. Dockerfile ile bir uygulama oluşturmak için, func init
üzerinde--dockerfile seçeneğini kullanın.To create an app with a Dockerfile, use the --dockerfile option on func init
.
func deploy
Aşağıdaki özel kapsayıcı dağıtım seçenekleri kullanılabilir:The following custom container deployment options are available:
SeçenekOption | AçıklamaDescription |
---|---|
--registry |
Geçerli kullanıcının oturum açan bir Docker kayıt defterinin adı.The name of a Docker Registry the current user signed-in to. |
--platform |
İşlev uygulaması için platform barındırma.Hosting platform for the function app. Geçerli seçenekler şunlardır kubernetes Valid options are kubernetes |
--name |
İşlev uygulaması adı.Function app name. |
--max |
İsteğe bağlı olarak, dağıtılacak maksimum işlev uygulaması örneği sayısını ayarlar.Optionally, sets the maximum number of function app instances to deploy to. |
--min |
İsteğe bağlı olarak, dağıtılacak en düşük işlev uygulaması örneği sayısını ayarlar.Optionally, sets the minimum number of function app instances to deploy to. |
--config |
İsteğe bağlı bir dağıtım yapılandırma dosyası ayarlar.Sets an optional deployment configuration file. |
İzleme işlevleriMonitoring functions
İşlevlerinizin yürütülmesini izlemek için önerilen yol, Azure Application Insights ile tümleştirilmesine göre yapılır.The recommended way to monitor the execution of your functions is by integrating with Azure Application Insights. Ayrıca, yürütme günlüklerini yerel bilgisayarınıza da akışla aktarabilirsiniz.You can also stream execution logs to your local computer. Daha fazla bilgi için bkz. Azure Işlevlerini izleme.To learn more, see Monitor Azure Functions.
Application Insights tümleştirmeyi etkinleştirEnable Application Insights integration
Azure portal bir işlev uygulaması oluşturduğunuzda, Application Insights tümleştirmesi varsayılan olarak sizin için yapılır.When you create a function app in the Azure portal, the Application Insights integration is done for you by default. Ancak, Azure CLı kullanarak işlev uygulamanızı oluşturduğunuzda, Azure 'daki işlev uygulamanızda tümleştirme yapılmaz.However, when you create your function app by using the Azure CLI, the integration in your function app in Azure isn't done.
İşlevler, Azure Portalbir işlev uygulamasına Application Insights tümleştirme eklemeyi kolaylaştırır.Functions makes it easy to add Application Insights integration to a function app from the Azure portal.
Portal tüm hizmetler > işlev uygulamaları' nı seçin, işlev uygulamanızı seçin ve ardından pencerenin üst kısmındaki Application Insights başlığını seçinIn the portal, select All services > Function Apps, select your function app, and then select the Application Insights banner at the top of the window
Görüntünün altındaki tabloda belirtilen ayarları kullanarak bir Application Insights kaynağı oluşturun.Create an Application Insights resource by using the settings specified in the table below the image.
AyarSetting Önerilen değerSuggested value AçıklamaDescription NameName Benzersiz uygulama adıUnique app name Kendi aboneliğinizde benzersiz olması gereken işlev uygulamanız ile aynı adı kullanmak en kolay yoldur.It's easiest to use the same name as your function app, which must be unique in your subscription. LocationLocation Batı AvrupaWest Europe Mümkünse, işlev uygulamanız ile aynı bölgeyi veya bu bölgeye yakın olanı kullanın.If possible, use the same region as your function app, or one that's close to that region. Tamam’ı seçin.Select OK. Application Insights kaynak, işlev uygulamanız ile aynı kaynak grubunda ve abonelikte oluşturulur.The Application Insights resource is created in the same resource group and subscription as your function app. Kaynak oluşturulduktan sonra Application Insights penceresini kapatın.After the resource is created, close the Application Insights window.
İşlev uygulamanıza geri dönün, uygulama ayarları' nı seçin ve ardından uygulama ayarları' na kaydırın.Back in your function app, select Application settings, and then scroll down to Application settings. Adlı
APPINSIGHTS_INSTRUMENTATIONKEY
bir ayar görürseniz, Azure 'da çalışan işlev uygulamanız için Application Insights tümleştirme etkinleştirilir.If you see a setting namedAPPINSIGHTS_INSTRUMENTATIONKEY
, Application Insights integration is enabled for your function app running in Azure.
Akış günlüklerini etkinleştirEnable streaming logs
İşlevleriniz tarafından oluşturulan günlük dosyalarının akışını, yerel bilgisayarınızdaki bir komut satırı oturumunda görüntüleyebilirsiniz.You can view a stream of log files being generated by your functions in a command-line session on your local computer.
Yerel akış günlükleriNative streaming logs
Yerleşik günlük akışıBuilt-in log streaming
Aşağıdaki örnekte olduğu gibi, Azure 'da çalışan belirli bir işlev uygulamasının akış günlüklerini almaya başlamak için seçeneğinikullanın:logstream
Use the logstream
option to start receiving streaming logs of a specific function app running in Azure, as in the following example:
func azure functionapp logstream <FunctionAppName>
Canlı Ölçüm AkışıLive Metrics Stream
Ayrıca, aşağıdaki örnekte olduğu gibi --browser
seçeneğini ekleyerek işlev uygulamanızın canlı ölçüm akışı yeni bir tarayıcı penceresinde görüntüleyebilirsiniz:You can also view the Live Metrics Stream for your function app in a new browser window by including the --browser
option, as in the following example:
func azure functionapp logstream <FunctionAppName> --browser
Bu tür akış günlükleri, işlev uygulamanız için Application Insights tümleştirmeyi etkinleştirmenizi gerektirir.This type of streaming logs requires that you enable Application Insights integration for your function app.
Sonraki adımlarNext steps
Microsoft Azure Functions Core Tools kullanarak Azure işlevleri geliştirmeyi, test yapmayı ve yayımlamayı öğrenin Azure Functions Core Tools açık kaynak ve GitHub üzerinde barındırılır.Learn how to develop, test, and publish Azure Functions by using Azure Functions Core Tools Microsoft learn module Azure Functions Core Tools is open source and hosted on GitHub.
Bir hata veya özellik isteğini dosyabir GitHub sorunu açın.To file a bug or feature request, open a GitHub issue.
Geri Bildirim
Geri bildirim yükleniyor...