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/container-instances/container-instances-tutorial-azure-function-trigger.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@ In this tutorial, you create an Azure function that takes an HTTP request and tr
21
21
You learn how to:
22
22
23
23
> [!div class="checklist"]
24
-
> * Use Visual Studio Code with the [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) to create a basic HTTP-triggered PowerShell function locally. Then, deploy it to a function app in Azure.
24
+
> * Use Visual Studio Code with the [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) to create a basic HTTP-triggered PowerShell function.
25
25
> * Enable an identity in the function app and give it permissions to create Azure resources.
26
-
> * Modify and republish the PowerShell function code to automate deployment of a single-container container group.
26
+
> * Modify and republish the PowerShell function to automate deployment of a single-container container group.
27
27
> * Verify the HTTP-triggered deployment of the container.
28
28
29
29
> [!IMPORTANT]
@@ -35,7 +35,7 @@ See [Create your first PowerShell function in Azure](../azure-functions/function
35
35
36
36
Some steps in this article use the Azure CLI. You can use the Azure Cloud Shell or a local installation of the Azure CLI to complete these steps. If you need to install or upgrade, see [Install Azure CLI][azure-cli-install].
37
37
38
-
## Create a simple PowerShell function
38
+
## Create a basic PowerShell function
39
39
40
40
Follow steps in [Create your first PowerShell function in Azure](../azure-functions/functions-create-first-function-powershell.md) to create a PowerShell function using the HTTP Trigger template. Use the default Azure function name **HttpTrigger**. As shown in the quckstart, test the function locally, and publish the project to a function app in Azure. This example is a basic HTTP-triggered function that returns a text string. In later steps in this article, you modify the function to create a container group.
41
41
@@ -65,17 +65,18 @@ az functionapp identity assign \
65
65
Update the PowerShell code for the **HttpTrigger** function to create a container group. In file `run.ps1` for the function, find the following code block. This code displays a name value, if one is passed as a query string in the function URL:
66
66
67
67
```powershell
68
-
...
68
+
[...]
69
69
if ($name) {
70
70
$status = [HttpStatusCode]::OK
71
71
$body = "Hello $name"
72
72
}
73
-
...
73
+
[...]
74
74
```
75
75
76
76
Replace this code with the following example block. Here, if a name value is passed in the query string, it is used to name and create a container group using the [New-AzContainerGroup][new-azcontainergroup] cmdlet. Make sure to replace the resource group name *myfunctionapp* with the name of the resource group for your function app:
This example creates a container group consisting of a single container instance running the `alpine` image. The container runs a single `echo` command and then terminates. In a real-world example, you might trigger creation of one or more container groups for running a batch job.
@@ -117,7 +118,7 @@ The function URL includes a unique code and is of the form:
@@ -198,9 +199,9 @@ az group delete --name myfunctionapp
198
199
In this tutorial, you created an Azure function that takes an HTTP request and triggers deployment of a container group. You learned how to:
199
200
200
201
> [!div class="checklist"]
201
-
> * Use Visual Studio Code with the Azure Functions extension to create a basic HTTP-triggered PowerShell function locally. Then, deploy it to a function app in Azure.
202
+
> * Use Visual Studio Code with the Azure Functions extension to create a basic HTTP-triggered PowerShell function.
202
203
> * Enable an identity in the function app and give it permissions to create Azure resources.
203
-
> * Modify and republish the PowerShell function code to automate deployment of a single-container container group.
204
+
> * Modify the PowerShell function code to automate deployment of a single-container container group.
204
205
> * Verify the HTTP-triggered deployment of the container.
205
206
206
207
For a detailed example to launch and monitor a containerized job, see the blog post [Event-Driven Serverless Containers with PowerShell Azure Functions and Azure Container Instances](https://dev.to/azure/event-driven-serverless-containers-with-powershell-azure-functions-and-azure-container-instances-e9b) and accompanying [code sample](https://github.com/anthonychu/functions-powershell-run-aci).
0 commit comments