-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathStorageAccountAttribute.cs
55 lines (51 loc) · 2.16 KB
/
StorageAccountAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
namespace Microsoft.Azure.WebJobs
{
/// <summary>
/// Attribute used to override the default Azure Storage account used by triggers and binders.
/// </summary>
/// <remarks>
/// This attribute can be applied at the parameter/method/class level, and the precedence
/// is in that order.
/// </remarks>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter)]
public sealed class StorageAccountAttribute : Attribute, IConnectionProvider
{
/// <summary>
/// Constructs a new instance.
/// </summary>
/// <param name="account">A string value indicating the Azure Storage connection string to use. This
/// string should be in one of the following formats. These checks will be applied in order and the
/// first match wins.
/// - The name of an "AzureWebJobs" prefixed app setting or connection string name. E.g., if your setting
/// name is "AzureWebJobsMyStorage", you can specify "MyStorage" here.
/// - Can be a string containing %% values (e.g. %StagingStorage%). The value provided will be passed
/// to any INameResolver registered on the JobHostConfiguration to resolve the actual setting name to use.
/// - Can be an app setting or connection string name of your choosing.
/// </param>
public StorageAccountAttribute(string account)
{
Account = account;
}
/// <summary>
/// Gets or sets the app setting name that contains the Azure Storage connection string.
/// </summary>
public string Account { get; private set; }
/// <summary>
/// Gets or sets the app setting name that contains the Azure Storage connection string.
/// </summary>
string IConnectionProvider.Connection
{
get
{
return Account;
}
set
{
Account = value;
}
}
}
}