Skip to content

Commit fc8aa0d

Browse files
committed
multi-connection support for NH, DocDB, EasyTables; updating extension Nugets
1 parent ed7c143 commit fc8aa0d

16 files changed

+104
-112
lines changed

src/WebJobs.Script.Host/WebJobs.Script.Host.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@
7979
<Private>True</Private>
8080
</Reference>
8181
<Reference Include="Microsoft.Azure.WebJobs.Extensions, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
82-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.1.0.2-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.dll</HintPath>
82+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.1.0.2-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.dll</HintPath>
8383
<Private>True</Private>
8484
</Reference>
8585
<Reference Include="Microsoft.Azure.WebJobs.Extensions.DocumentDB, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
86-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.DocumentDB.1.0.0-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.DocumentDB.dll</HintPath>
86+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.DocumentDB.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.DocumentDB.dll</HintPath>
8787
<Private>True</Private>
8888
</Reference>
8989
<Reference Include="Microsoft.Azure.WebJobs.Extensions.EasyTables, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
90-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.EasyTables.1.0.0-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.EasyTables.dll</HintPath>
90+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.EasyTables.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.EasyTables.dll</HintPath>
9191
<Private>True</Private>
9292
</Reference>
9393
<Reference Include="Microsoft.Azure.WebJobs.Extensions.NotificationHubs, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
94-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.1.0.0-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.dll</HintPath>
94+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.dll</HintPath>
9595
<Private>True</Private>
9696
</Reference>
9797
<Reference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
98-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.SendGrid.1.0.2-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.SendGrid.dll</HintPath>
98+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.SendGrid.1.0.2-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.SendGrid.dll</HintPath>
9999
<Private>True</Private>
100100
</Reference>
101101
<Reference Include="Microsoft.Azure.WebJobs.Host, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

src/WebJobs.Script.Host/packages.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
<package id="Microsoft.Azure.ServiceBus.EventProcessorHost" version="1.4.0" targetFramework="net46" />
1313
<package id="Microsoft.Azure.WebJobs" version="1.1.2-alpha-10282" targetFramework="net46" />
1414
<package id="Microsoft.Azure.WebJobs.Core" version="1.1.2-alpha-10282" targetFramework="net46" />
15-
<package id="Microsoft.Azure.WebJobs.Extensions" version="1.0.2-alpha-10258" targetFramework="net46" />
16-
<package id="Microsoft.Azure.WebJobs.Extensions.DocumentDB" version="1.0.0-alpha-10258" targetFramework="net46" />
17-
<package id="Microsoft.Azure.WebJobs.Extensions.EasyTables" version="1.0.0-alpha-10258" targetFramework="net46" />
18-
<package id="Microsoft.Azure.WebJobs.Extensions.NotificationHubs" version="1.0.0-alpha-10258" targetFramework="net46" />
19-
<package id="Microsoft.Azure.WebJobs.Extensions.SendGrid" version="1.0.2-alpha-10258" targetFramework="net46" />
15+
<package id="Microsoft.Azure.WebJobs.Extensions" version="1.0.2-alpha-10260" targetFramework="net46" />
16+
<package id="Microsoft.Azure.WebJobs.Extensions.DocumentDB" version="1.0.0-alpha-10260" targetFramework="net46" />
17+
<package id="Microsoft.Azure.WebJobs.Extensions.EasyTables" version="1.0.0-alpha-10260" targetFramework="net46" />
18+
<package id="Microsoft.Azure.WebJobs.Extensions.NotificationHubs" version="1.0.0-alpha-10260" targetFramework="net46" />
19+
<package id="Microsoft.Azure.WebJobs.Extensions.SendGrid" version="1.0.2-alpha-10260" targetFramework="net46" />
2020
<package id="Microsoft.Azure.WebJobs.ServiceBus" version="1.1.2-alpha-10282" targetFramework="net46" />
2121
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
2222
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net46" />

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,24 +123,32 @@
123123
<HintPath>..\..\packages\Microsoft.Azure.DocumentDB.1.5.3\lib\net40\Microsoft.Azure.Documents.Client.dll</HintPath>
124124
<Private>True</Private>
125125
</Reference>
126+
<Reference Include="Microsoft.Azure.NotificationHubs, Version=2.16.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
127+
<HintPath>..\..\packages\Microsoft.Azure.NotificationHubs.1.0.3\lib\net45-full\Microsoft.Azure.NotificationHubs.dll</HintPath>
128+
<Private>True</Private>
129+
</Reference>
126130
<Reference Include="Microsoft.Azure.WebJobs, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
127131
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Core.1.1.2-alpha-10282\lib\net45\Microsoft.Azure.WebJobs.dll</HintPath>
128132
<Private>True</Private>
129133
</Reference>
130134
<Reference Include="Microsoft.Azure.WebJobs.Extensions, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
131-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.1.0.2-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.dll</HintPath>
135+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.1.0.2-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.dll</HintPath>
132136
<Private>True</Private>
133137
</Reference>
134138
<Reference Include="Microsoft.Azure.WebJobs.Extensions.DocumentDB, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
135-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.DocumentDB.1.0.0-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.DocumentDB.dll</HintPath>
139+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.DocumentDB.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.DocumentDB.dll</HintPath>
136140
<Private>True</Private>
137141
</Reference>
138142
<Reference Include="Microsoft.Azure.WebJobs.Extensions.EasyTables, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
139-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.EasyTables.1.0.0-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.EasyTables.dll</HintPath>
143+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.EasyTables.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.EasyTables.dll</HintPath>
144+
<Private>True</Private>
145+
</Reference>
146+
<Reference Include="Microsoft.Azure.WebJobs.Extensions.NotificationHubs, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
147+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.1.0.0-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.NotificationHubs.dll</HintPath>
140148
<Private>True</Private>
141149
</Reference>
142150
<Reference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
143-
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.SendGrid.1.0.2-alpha-10258\lib\net45\Microsoft.Azure.WebJobs.Extensions.SendGrid.dll</HintPath>
151+
<HintPath>..\..\packages\Microsoft.Azure.WebJobs.Extensions.SendGrid.1.0.2-alpha-10260\lib\net45\Microsoft.Azure.WebJobs.Extensions.SendGrid.dll</HintPath>
144152
<Private>True</Private>
145153
</Reference>
146154
<Reference Include="Microsoft.Azure.WebJobs.Host, Version=1.1.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">

src/WebJobs.Script.WebHost/packages.config

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
<package id="Microsoft.AspNet.WebHooks.Receivers.WordPress" version="1.2.0-beta6" targetFramework="net45" />
2525
<package id="Microsoft.Azure.DocumentDB" version="1.5.3" targetFramework="net46" />
2626
<package id="Microsoft.Azure.Mobile.Client" version="2.0.1" targetFramework="net46" />
27+
<package id="Microsoft.Azure.NotificationHubs" version="1.0.3" targetFramework="net46" />
2728
<package id="Microsoft.Azure.WebJobs" version="1.1.2-alpha-10282" targetFramework="net46" />
2829
<package id="Microsoft.Azure.WebJobs.Core" version="1.1.2-alpha-10282" targetFramework="net46" />
29-
<package id="Microsoft.Azure.WebJobs.Extensions" version="1.0.2-alpha-10258" targetFramework="net46" />
30-
<package id="Microsoft.Azure.WebJobs.Extensions.DocumentDB" version="1.0.0-alpha-10258" targetFramework="net46" />
31-
<package id="Microsoft.Azure.WebJobs.Extensions.EasyTables" version="1.0.0-alpha-10258" targetFramework="net46" />
32-
<package id="Microsoft.Azure.WebJobs.Extensions.SendGrid" version="1.0.2-alpha-10258" targetFramework="net46" />
30+
<package id="Microsoft.Azure.WebJobs.Extensions" version="1.0.2-alpha-10260" targetFramework="net46" />
31+
<package id="Microsoft.Azure.WebJobs.Extensions.DocumentDB" version="1.0.0-alpha-10260" targetFramework="net46" />
32+
<package id="Microsoft.Azure.WebJobs.Extensions.EasyTables" version="1.0.0-alpha-10260" targetFramework="net46" />
33+
<package id="Microsoft.Azure.WebJobs.Extensions.NotificationHubs" version="1.0.0-alpha-10260" targetFramework="net46" />
34+
<package id="Microsoft.Azure.WebJobs.Extensions.SendGrid" version="1.0.2-alpha-10260" targetFramework="net46" />
3335
<package id="Microsoft.Azure.WebJobs.ServiceBus" version="1.1.2-alpha-10282" targetFramework="net46" />
3436
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
3537
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net46" />

src/WebJobs.Script/Binding/DocumentDBBinding.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public DocumentDBBinding(ScriptHostConfiguration config, DocumentDBBindingMetada
2424
DatabaseName = metadata.DatabaseName;
2525
CollectionName = metadata.CollectionName;
2626
CreateIfNotExists = metadata.CreateIfNotExists;
27+
ConnectionString = metadata.Connection;
2728
_bindingDirection = metadata.Direction;
2829
}
2930

@@ -33,6 +34,8 @@ public DocumentDBBinding(ScriptHostConfiguration config, DocumentDBBindingMetada
3334

3435
public bool CreateIfNotExists { get; private set; }
3536

37+
public string ConnectionString { get; private set; }
38+
3639
public override bool HasBindingParameters
3740
{
3841
get
@@ -44,24 +47,29 @@ public override bool HasBindingParameters
4447
public override Collection<CustomAttributeBuilder> GetCustomAttributes()
4548
{
4649
Type attributeType = typeof(DocumentDBAttribute);
50+
51+
object[] constructorValues = new object[]
52+
{
53+
DatabaseName,
54+
CollectionName
55+
};
56+
4757
PropertyInfo[] props = new[]
4858
{
49-
attributeType.GetProperty("DatabaseName"),
50-
attributeType.GetProperty("CollectionName"),
51-
attributeType.GetProperty("CreateIfNotExists")
59+
attributeType.GetProperty("CreateIfNotExists"),
60+
attributeType.GetProperty("ConnectionString")
5261
};
5362

5463
object[] propValues = new object[]
5564
{
56-
DatabaseName,
57-
CollectionName,
58-
CreateIfNotExists
65+
CreateIfNotExists,
66+
ConnectionString
5967
};
6068

61-
ConstructorInfo constructor = attributeType.GetConstructor(System.Type.EmptyTypes);
69+
ConstructorInfo constructor = attributeType.GetConstructor(new[] { typeof(string), typeof(string) });
6270
return new Collection<CustomAttributeBuilder>()
6371
{
64-
new CustomAttributeBuilder(constructor, new object[] { }, props, propValues)
72+
new CustomAttributeBuilder(constructor, constructorValues, props, propValues)
6573
};
6674
}
6775

@@ -70,11 +78,10 @@ public override async Task BindAsync(BindingContext context)
7078
// Only output bindings are supported.
7179
if (Access == FileAccess.Write && _bindingDirection == BindingDirection.Out)
7280
{
73-
DocumentDBAttribute attribute = new DocumentDBAttribute
81+
DocumentDBAttribute attribute = new DocumentDBAttribute(DatabaseName, CollectionName)
7482
{
75-
DatabaseName = DatabaseName,
76-
CollectionName = CollectionName,
77-
CreateIfNotExists = CreateIfNotExists
83+
CreateIfNotExists = CreateIfNotExists,
84+
ConnectionString = ConnectionString
7885
};
7986

8087
RuntimeBindingContext runtimeContext = new RuntimeBindingContext(attribute);

src/WebJobs.Script/Binding/EasyTableBinding.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,20 @@ public EasyTableBinding(ScriptHostConfiguration config, EasyTableBindingMetadata
2222
{
2323
TableName = metadata.TableName;
2424
Id = metadata.Id;
25+
MobileAppUri = metadata.Connection;
26+
ApiKey = metadata.ApiKey;
27+
2528
_bindingDirection = metadata.Direction;
2629
}
2730

2831
public string TableName { get; private set; }
2932

3033
public string Id { get; private set; }
3134

35+
public string MobileAppUri { get; private set; }
36+
37+
public string ApiKey { get; private set; }
38+
3239
public override bool HasBindingParameters
3340
{
3441
get
@@ -42,13 +49,17 @@ public override Collection<CustomAttributeBuilder> GetCustomAttributes()
4249
PropertyInfo[] props = new[]
4350
{
4451
typeof(EasyTableAttribute).GetProperty("TableName"),
45-
typeof(EasyTableAttribute).GetProperty("Id")
52+
typeof(EasyTableAttribute).GetProperty("Id"),
53+
typeof(EasyTableAttribute).GetProperty("MobileAppUri"),
54+
typeof(EasyTableAttribute).GetProperty("ApiKey"),
4655
};
4756

4857
object[] propValues = new[]
4958
{
5059
TableName,
51-
Id
60+
Id,
61+
MobileAppUri,
62+
ApiKey
5263
};
5364

5465
ConstructorInfo constructor = typeof(EasyTableAttribute).GetConstructor(System.Type.EmptyTypes);
@@ -67,7 +78,9 @@ public override async Task BindAsync(BindingContext context)
6778
EasyTableAttribute attribute = new EasyTableAttribute
6879
{
6980
TableName = TableName,
70-
Id = Id
81+
Id = Id,
82+
MobileAppUri = MobileAppUri,
83+
ApiKey = ApiKey
7184
};
7285

7386
RuntimeBindingContext runtimeContext = new RuntimeBindingContext(attribute);

src/WebJobs.Script/Binding/NotificationHubBinding.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ public NotificationHubBinding(ScriptHostConfiguration config, NotificationHubBin
2121
base(config, metadata, access)
2222
{
2323
TagExpression = metadata.TagExpression;
24+
ConnectionString = metadata.Connection;
25+
HubName = metadata.HubName;
26+
2427
_bindingDirection = metadata.Direction;
2528
}
2629

2730
public string TagExpression { get; private set; }
2831

32+
public string ConnectionString { get; private set; }
33+
34+
public string HubName { get; private set; }
35+
2936
public override bool HasBindingParameters
3037
{
3138
get
@@ -39,12 +46,16 @@ public override Collection<CustomAttributeBuilder> GetCustomAttributes()
3946
Type attributeType = typeof(NotificationHubAttribute);
4047
PropertyInfo[] props = new[]
4148
{
42-
attributeType.GetProperty("TagExpression")
49+
attributeType.GetProperty("TagExpression"),
50+
attributeType.GetProperty("ConnectionString"),
51+
attributeType.GetProperty("HubName")
4352
};
4453

4554
object[] propValues = new object[]
4655
{
47-
TagExpression
56+
TagExpression,
57+
ConnectionString,
58+
HubName
4859
};
4960

5061
ConstructorInfo constructor = attributeType.GetConstructor(System.Type.EmptyTypes);
@@ -61,7 +72,9 @@ public override async Task BindAsync(BindingContext context)
6172
{
6273
NotificationHubAttribute attribute = new NotificationHubAttribute
6374
{
64-
TagExpression = TagExpression
75+
TagExpression = TagExpression,
76+
ConnectionString = ConnectionString,
77+
HubName = HubName
6578
};
6679

6780
RuntimeBindingContext runtimeContext = new RuntimeBindingContext(attribute);

src/WebJobs.Script/Config/JobHostConfigurationBuilder.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public JobHostConfigurationBuilder(JobHostConfiguration config)
2121
public void Done()
2222
{
2323
this.Config.UseEventHub(this.EventHubConfiguration);
24+
this.Config.UseEasyTables();
25+
this.Config.UseDocumentDB();
26+
this.Config.UseNotificationHubs();
2427
}
2528
}
2629
}
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
5-
using Microsoft.Azure.WebJobs.Extensions.DocumentDB;
6-
74
namespace Microsoft.Azure.WebJobs.Script.Description
85
{
96
internal class DocumentDBBindingMetadata : BindingMetadata
@@ -13,21 +10,5 @@ internal class DocumentDBBindingMetadata : BindingMetadata
1310
public string CollectionName { get; set; }
1411

1512
public bool CreateIfNotExists { get; set; }
16-
17-
public override void ApplyToConfig(JobHostConfigurationBuilder configBuilder)
18-
{
19-
if (configBuilder == null)
20-
{
21-
throw new ArgumentNullException("configBuilder");
22-
}
23-
24-
DocumentDBConfiguration config = new DocumentDBConfiguration();
25-
if (!string.IsNullOrEmpty(Connection))
26-
{
27-
config.ConnectionString = Utility.GetAppSettingOrEnvironmentValue(Connection);
28-
}
29-
30-
configBuilder.Config.UseDocumentDB(config);
31-
}
3213
}
3314
}
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
5-
64
namespace Microsoft.Azure.WebJobs.Script.Description
75
{
86
public class EasyTableBindingMetadata : BindingMetadata
@@ -11,14 +9,6 @@ public class EasyTableBindingMetadata : BindingMetadata
119

1210
public string Id { get; set; }
1311

14-
public override void ApplyToConfig(JobHostConfigurationBuilder configBuilder)
15-
{
16-
if (configBuilder == null)
17-
{
18-
throw new ArgumentNullException("configBuilder");
19-
}
20-
21-
configBuilder.Config.UseEasyTables();
22-
}
12+
public string ApiKey { get; set; }
2313
}
2414
}

0 commit comments

Comments
 (0)