Skip to content

Commit 57c94ac

Browse files
Merge pull request #284877 from mattchenderson/webjobs-deps
adding explicit dependencies example
2 parents ebaa88d + 353766f commit 57c94ac

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

articles/app-service/webjobs-sdk-how-to.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,35 @@ For example, the `connection` property for an Azure Blob trigger definition migh
5050

5151
#### Identity-based connections
5252

53-
To use identity-based connections in the WebJobs SDK, make sure you are using the latest versions of WebJobs packages in your project. You should also ensure you have a reference to [Microsoft.Azure.WebJobs.Host.Storage](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Host.Storage). When setting up WebJobs within your HostBuilder, make sure to include a call to `AddAzureStorageCoreServices`, as this is what allows `AzureWebJobsStorage` and other Storage triggers and bindings to use identity:
53+
To use identity-based connections in the WebJobs SDK, make sure you are using the latest versions of WebJobs packages in your project. You should also ensure you have a reference to [Microsoft.Azure.WebJobs.Host.Storage](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Host.Storage). The following is an example of what your project file might look like after making these updates:
54+
55+
```xml
56+
<Project Sdk="Microsoft.NET.Sdk">
57+
58+
<PropertyGroup>
59+
<OutputType>Exe</OutputType>
60+
<TargetFramework>net48</TargetFramework>
61+
<IsWebJobProject>true</IsWebJobProject>
62+
<WebJobName>$(AssemblyName)</WebJobName>
63+
<WebJobType>Continuous</WebJobType>
64+
</PropertyGroup>
65+
66+
<ItemGroup>
67+
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.41" />
68+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage.Queues" Version="5.3.1" />
69+
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="5.0.1" />
70+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
71+
</ItemGroup>
72+
73+
<ItemGroup>
74+
<None Update="appsettings.json">
75+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
76+
</None>
77+
</ItemGroup>
78+
</Project>
79+
```
80+
81+
When setting up WebJobs within your HostBuilder, make sure to include a call to `AddAzureStorageCoreServices`, as this is what allows `AzureWebJobsStorage` and other Storage triggers and bindings to use identity:
5482

5583
```csharp
5684
builder.ConfigureWebJobs(b =>
@@ -80,7 +108,7 @@ If you provide your configuration through any means other than environment varia
80108

81109
You may omit the `queueServiceUri` property if you do not plan to use blob triggers.
82110

83-
When your code is run locally, this will default to using your developer identity per the behavior described for DefaultAzureCredential.
111+
When your code is run locally, this will default to using your developer identity per the behavior described for [DefaultAzureCredential](/dotnet/api/azure.identity.defaultazurecredential).
84112

85113
When your code is hosted in Azure App Service, the configuration shown above will default to the [system-assigned managed identity](./overview-managed-identity.md#add-a-system-assigned-identity) for the resource. To instead use a [user-assigned identity](./overview-managed-identity.md#add-a-user-assigned-identity) which has been assigned to the app, you need to add additional properties for your connection that specify which identity should be used. The `credential` property (`AzureWebJobsStorage__credential` as an environment variable) should be set to the string "managedidentity". The `clientId` property (`AzureWebJobsStorage__clientId` as an environment variable) should be set to the client ID of the user-assigned managed identity to be used. As structured configuration, the complete object would be:
86114

0 commit comments

Comments
 (0)