You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/webjobs-sdk-get-started.md
+43-35Lines changed: 43 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,28 +34,31 @@ This article shows you how to deploy WebJobs as a .NET Core console app. To depl
34
34
35
35
## WebJobs NuGet packages
36
36
37
-
1. Install the latest stable 3.x version of the `Microsoft.Azure.WebJobs.Extensions` NuGet package, which includes `Microsoft.Azure.WebJobs`.
37
+
1. Install the latest stable 3.x version of the [`Microsoft.Azure.WebJobs.Extensions` NuGet package](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions/), which includes `Microsoft.Azure.WebJobs`.
38
38
39
-
Here's the **Package Manager Console** command for version 3.0.2:
In this command, replace `<3_X_VERSION>` with a supported version of the package.
46
+
45
47
## Create the Host
46
48
47
49
The host is the runtime container for functions that listens for triggers and calls functions. The following steps create a host that implements [`IHost`](/dotnet/api/microsoft.extensions.hosting.ihost), which is the Generic Host in ASP.NET Core.
48
50
49
-
1. In *Program.cs*, add a `using` statement:
51
+
1. In *Program.cs*, add these `using` statements:
50
52
51
53
```cs
54
+
using System.Threading.Tasks;
52
55
using Microsoft.Extensions.Hosting;
53
56
```
54
57
55
58
1. Replace the `Main` method with the following code:
56
59
57
60
```cs
58
-
static void Main(string[] args)
61
+
static async Task Main()
59
62
{
60
63
var builder = new HostBuilder();
61
64
builder.ConfigureWebJobs(b =>
@@ -65,7 +68,7 @@ The host is the runtime container for functions that listens for triggers and ca
65
68
var host = builder.Build();
66
69
using (host)
67
70
{
68
-
host.Run();
71
+
await host.RunAsync();
69
72
}
70
73
}
71
74
```
@@ -76,12 +79,12 @@ In ASP.NET Core, host configurations are set by calling methods on the [`HostBui
76
79
77
80
In this section, you set up console logging that uses the [ASP.NET Core logging framework](/aspnet/core/fundamentals/logging).
78
81
79
-
1. Install the latest stable version of the `Microsoft.Extensions.Logging.Console` NuGet package, which includes `Microsoft.Extensions.Logging`.
82
+
1. Install the latest stable version of the [`Microsoft.Extensions.Logging.Console` NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/), which includes `Microsoft.Extensions.Logging`.
80
83
81
-
Here's the **Package Manager Console** command for version 2.2.0:
@@ -90,6 +93,8 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
90
93
usingMicrosoft.Extensions.Logging;
91
94
```
92
95
96
+
In this command, replace `<3_X_VERSION>` with a supported 3.x version of the package.
97
+
93
98
1. Call the [`ConfigureLogging`](/dotnet/api/microsoft.aspnetcore.hosting.webhostbuilderextensions.configurelogging) method on [`HostBuilder`](/dotnet/api/microsoft.extensions.hosting.hostbuilder). The [`AddConsole`](/dotnet/api/microsoft.extensions.logging.consoleloggerextensions.addconsole) method adds console logging to the configuration.
94
99
95
100
```cs
@@ -102,7 +107,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
102
107
The `Main` methodnowlookslikethis:
103
108
104
109
```cs
105
-
staticvoidMain(string[] args)
110
+
staticasyncTaskMain()
106
111
{
107
112
varbuilder=newHostBuilder();
108
113
builder.ConfigureWebJobs(b=>
@@ -116,7 +121,7 @@ In this section, you set up console logging that uses the [ASP.NET Core logging
116
121
varhost=builder.Build();
117
122
using (host)
118
123
{
119
-
host.Run();
124
+
awaithost.RunAsync();
120
125
}
121
126
}
122
127
```
@@ -134,11 +139,13 @@ Starting with version 3.x, you must explicitly install the Storage binding exten
134
139
135
140
1. Installthelateststableversionofthe [Microsoft.Azure.WebJobs.Extensions.Storage](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Storage) NuGet package, version 3.x.
136
141
137
-
Here's the **Package Manager Console** command for version 3.0.4:
The `QueueTrigger` attribute tells the runtime to call the function whenever a queue message appears in the `myqueue-items` queue. The `Blob` attribute tells the runtime to use the queue message to read a blob in the *sample-workitems* container. The content of the queue message, passed in to the function in the `myQueueItem` parameter, is the name of the blob.
162
+
The `QueueTrigger` attribute tells the runtime to call the function whenever a queue message appears in the `myqueue-items` queue. The `Blob` attribute tells the runtime to use the queue message to read a blob in the *sample-workitems* container. The name of the blob item in the `samples-workitems` container is obtained directly from the queue trigger as a binding expression (`{queueTrigger}`).
Add a `notifications` section to the `durableTask` property of the file, replacing `<topic_name>` with the name you chose. If the `durableTask` or `extensions` properties do not exist, create them like this example:
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/templates/template-tutorial-use-key-vault.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
title: Use Azure Key Vault in templates
3
3
description: Learn how to use Azure Key Vault to pass secure parameter values during Resource Manager template deployment
4
4
author: mumian
5
-
ms.date: 05/23/2019
5
+
ms.date: 04/16/2020
6
6
ms.topic: tutorial
7
7
ms.author: jgao
8
8
ms.custom: seodec18
9
9
---
10
10
11
11
# Tutorial: Integrate Azure Key Vault in your ARM template deployment
12
12
13
-
Learn how to retrieve secrets from an Azure key vault and pass the secrets as parameters when you deploy an Azure Resource Manager (ARM) template. The parameter value is never exposed, because you reference only its key vault ID. For more information, see [Use Azure Key Vault to pass secure parameter value during deployment](./key-vault-parameter.md).
13
+
Learn how to retrieve secrets from an Azure key vault and pass the secrets as parameters when you deploy an Azure Resource Manager (ARM) template. The parameter value is never exposed, because you reference only its key vault ID. You can reference the key vault secret by using a static ID or a dynamic ID. This tutorial uses a static ID. With the static ID approach, you reference the key vault in the template parameter file, not the template file. For more information about both approaches, see [Use Azure Key Vault to pass secure parameter value during deployment](./key-vault-parameter.md).
14
14
15
15
In the [Set resource deployment order](./template-tutorial-create-templates-with-dependent-resources.md) tutorial, you create a virtual machine (VM). You need to provide the VM administrator username and password. Instead of providing the password, you can pre-store the password in an Azure key vault and then customize the template to retrieve the password from the key vault during the deployment.
16
16
@@ -28,8 +28,6 @@ This tutorial covers the following tasks:
28
28
29
29
If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
@@ -44,7 +42,7 @@ To complete this article, you need:
44
42
45
43
## Prepare a key vault
46
44
47
-
In this section, you create a key vault and add a secret to it, so that you can retrieve the secret when you deploy your template. There are many ways to create a key vault. In this tutorial, you use Azure PowerShell to deploy an [ARM template](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorials-use-key-vault/CreateKeyVault.json). This template does the following:
45
+
In this section, you create a key vault and add a secret to it, so that you can retrieve the secret when you deploy your template. There are many ways to create a key vault. In this tutorial, you use Azure PowerShell to deploy an [ARM template](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorials-use-key-vault/CreateKeyVault.json). This template does two things:
48
46
49
47
* Creates a key vault with the `enabledForTemplateDeployment` property enabled. This property must be *true* before the template deployment process can access the secrets that are defined in the key vault.
50
48
* Adds a secret to the key vault. The secret stores the VM administrator password.
> * The resource group name is the project name, but with **rg** appended to it. To make it easier to [clean up the resources that you created in this tutorial](#clean-up-resources), use the same project name and resource group name when you [deploy the next template](#deploy-the-template).
74
74
> * The default name for the secret is **vmAdminPassword**. It's hardcoded in the template.
75
-
> * To enable the template to retrieve the secret, you must enable an access policy called "Enable access to Azure Resource Manager for template deployment" for the key vault. This policy is enabled in the template. For more information about the access policy, see [Deploy key vaults and secrets](./key-vault-parameter.md#deploy-key-vaults-and-secrets).
75
+
> * To enable the template to retrieve the secret, you must enable an access policy called **Enable access to Azure Resource Manager for template deployment** for the key vault. This policy is enabled in the template. For more information about the access policy, see [Deploy key vaults and secrets](./key-vault-parameter.md#deploy-key-vaults-and-secrets).
76
76
77
-
The template has one output value, called *keyVaultId*. Write down the ID value for later use, when you deploy the virtual machine. The resource ID format is:
77
+
The template has one output value, called *keyVaultId*. You will use this ID along with the secret name to retrieve the secret value later in the tutorial. The resource ID format is:
@@ -103,13 +103,14 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
103
103
```
104
104
105
105
1. Select **Open** to open the file. The scenario is the same as the one that's used in [Tutorial: Create ARM templates with dependent resources](./template-tutorial-create-templates-with-dependent-resources.md).
106
-
The template defines five resources:
106
+
The template defines six resources:
107
107
108
-
* `Microsoft.Storage/storageAccounts`. See the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
109
-
* `Microsoft.Network/publicIPAddresses`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
110
-
* `Microsoft.Network/virtualNetworks`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks).
111
-
* `Microsoft.Network/networkInterfaces`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces).
112
-
* `Microsoft.Compute/virtualMachines`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines).
It's helpful to have some basic understanding of the template before you customize it.
115
116
@@ -123,7 +124,7 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
123
124
124
125
## Edit the parameters file
125
126
126
-
You don't need to make any changes to the template file.
127
+
By using the static ID method, you don't need to make any changes to the template file. Retrieving the secret value is done by configuring the template parameter file.
127
128
128
129
1. In Visual Studio Code, open *azuredeploy.parameters.json* if it's not already open.
129
130
1. Update the `adminPassword` parameter to:
@@ -140,7 +141,7 @@ You don't need to make any changes to the template file.
140
141
```
141
142
142
143
> [!IMPORTANT]
143
-
> Replace the value for **id** with the resource ID of the key vault that you created in the previous procedure.
144
+
> Replace the value for **id** with the resource ID of the key vault that you created in the previous procedure. The secretName is hardcoded as **vmAdminPassword**. See [Prepare a key vault](#prepare-a-key-vault).
0 commit comments