| author | ggailey777 |
|---|---|
| ms.service | azure-functions |
| ms.topic | include |
| ms.date | 12/8/2021 |
| ms.author | glenga |
You can also use the StorageAccountAttribute to specify the storage account to use. You can do this when you need to use a different storage account than other functions in the library. The constructor takes the name of an app setting that contains a storage connection string. The attribute can be applied at the parameter, method, or class level. The following example shows class level and method level:
[StorageAccount("ClassLevelStorageAppSetting")]
public static class AzureFunctions
{
[FunctionName("BlobTrigger")]
[StorageAccount("FunctionLevelStorageAppSetting")]
public static void Run( //...
{
....
}The storage account to use is determined in the following order:
- The
BlobTriggerattribute'sConnectionproperty. - The
StorageAccountattribute applied to the same parameter as theBlobTriggerattribute. - The
StorageAccountattribute applied to the function. - The
StorageAccountattribute applied to the class. - The default storage account for the function app, which is defined in the
AzureWebJobsStorageapplication setting.