Skip to content

Commit d9829c9

Browse files
authored
[Storage] Webjobs extension sample apps. (Azure#18358)
* nest sample tests? * queues sample app. * nesting. * new link. * blobs sample. * fix build. * fix build. * does this fix the build ?
1 parent 4ad9dd0 commit d9829c9

19 files changed

+241
-6
lines changed

sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ public static class BlobFunction_EnumerateBlobs_BlobClient
308308
}
309309
```
310310

311+
### Configuring the extension
312+
313+
Please refer to [sample functions app]<!--(https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/functionapp) TODO (kasobol-msft) uncomment post merge.-->.
314+
311315
## Troubleshooting
312316

313317
Please refer to [Monitor Azure Functions](https://docs.microsoft.com/azure/azure-functions/functions-monitoring) for troubleshooting guidance.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<!-- Signal that samples are building in the repo as opposed to a standalone download from Samples Browser -->
4+
<IsSamplesProject>true</IsSamplesProject>
5+
<IsPackable>false</IsPackable>
6+
<ExcludeFromCodeCoverage>true</ExcludeFromCodeCoverage>
7+
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
8+
</PropertyGroup>
9+
10+
<Import Project="..\..\Directory.Build.props" />
11+
12+
<PropertyGroup>
13+
<InheritDocEnabled>false</InheritDocEnabled>
14+
</PropertyGroup>
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<RequiredTargetFrameworks>netcoreapp3.1</RequiredTargetFrameworks>
4+
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
5+
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
10+
<PackageReference Include="Microsoft.NET.Sdk.Functions" VersionOverride="3.0.9" />
11+
</ItemGroup>
12+
<ItemGroup>
13+
<None Update="host.json">
14+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15+
</None>
16+
<None Update="local.settings.json">
17+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
19+
</None>
20+
</ItemGroup>
21+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Sample Azure Function App for Azure Azure WebJobs Storage Blobs
2+
3+
This sample Azure Function application shows usage of Azure Azure WebJobs Storage Blobs extension.
4+
`SampleFunctions` contains a pair of functions that work with an Azure Storage Blobs
5+
as well as sample configuration files `host.json` and `local.settings.json`. Settings present in `host.json` are optional and used values can be different than defaults.
6+
Connection string present in `local.settings.json` points to [Azurite](https://github.com/Azure/Azurite), however any valid connection string will work.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using Microsoft.Extensions.Logging;
6+
7+
namespace Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Function.App
8+
{
9+
/// <summary>
10+
/// A pair of sample functions. First that updates a blob on schedule and second that listens to blob changes.
11+
/// </summary>
12+
public static class SampleFunctions
13+
{
14+
/// <summary>
15+
/// This function executes on schedule, produces a new content and udpates the blob.
16+
/// </summary>
17+
[FunctionName("SampleBlobContentUpdater")]
18+
[return: Blob("sample-container/sample-blob")]
19+
public static string UpdateSampleBlobContent([TimerTrigger("*/30 * * * * *")] TimerInfo timerInfo, ILogger logger)
20+
{
21+
if (timerInfo.IsPastDue)
22+
{
23+
logger.LogInformation("Timer is running late!");
24+
}
25+
var now = DateTime.Now;
26+
logger.LogInformation($"C# Timer trigger function executed at: {now}");
27+
28+
return $"Sample blob content produced at: {now}";
29+
}
30+
31+
/// <summary>
32+
/// This functions is executed when blob is modified.
33+
/// </summary>
34+
[FunctionName("SampleBlobUpdateListener")]
35+
public static void OnBlobUpdate([BlobTrigger("sample-container/sample-blob")] string content, ILogger logger)
36+
{
37+
logger.LogInformation("Blob has been updated, content: {content}", content);
38+
}
39+
}
40+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "2.0",
3+
"logging": {
4+
"applicationInsights": {
5+
"samplingExcludedTypes": "Request",
6+
"samplingSettings": {
7+
"isEnabled": true
8+
}
9+
}
10+
},
11+
"extensions": {
12+
"blobs": {
13+
"maxDegreeOfParallelism": "5"
14+
}
15+
}
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
6+
}
7+
}

sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/BlobExtensionSamples.cs renamed to sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/readmes/BlobExtensionSamples.cs

File renamed without changes.

sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Tests.csproj renamed to sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/readmes/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</ItemGroup>
99

1010
<ItemGroup>
11-
<ProjectReference Include="..\..\Microsoft.Azure.WebJobs.Extensions.Storage.Common\tests\Microsoft.Azure.WebJobs.Extensions.Storage.Common.Tests.csproj" />
12-
<ProjectReference Include="..\src\Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
11+
<ProjectReference Include="..\..\..\Microsoft.Azure.WebJobs.Extensions.Storage.Common\tests\Microsoft.Azure.WebJobs.Extensions.Storage.Common.Tests.csproj" />
12+
<ProjectReference Include="..\..\src\Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.csproj" />
1313
</ItemGroup>
1414
</Project>

sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ public static class Function_BindingToQueueClient
259259
}
260260
```
261261

262+
### Configuring the extension
263+
264+
Please refer to [sample functions app]<!--(https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/samples/functionapp) TODO (kasobol-msft) uncomment post merge.-->.
265+
262266
## Troubleshooting
263267

264268
Please refer to [Monitor Azure Functions](https://docs.microsoft.com/azure/azure-functions/functions-monitoring) for troubleshooting guidance.

0 commit comments

Comments
 (0)