The example demonstrate several Pulumi features:
- Azure-Native provider
- Running on .NET 5
- Using C# 9 constructs like top-level statements, implicit constuctors, and records
- Defining and using components with Pulumi
This example can cover several deployments architectures that are listed below.
You can deploy any public Docker image that contains a web application listening to port 80 to an Azure App Service. Modify the constructor of MyStack
class in Program.cs
file to
public MyStack()
{
var app = new WebApplication("hello", new()
{
DockerImage = "strm/helloworld-http"
});
this.Endpoint = app.Endpoint;
}
Builds a Docker container from the files in app
folder, push it to Azure Container Registry, and deploy it to an Azure App Service. Modify the constructor of MyStack
class in Program.cs
file to
public MyStack()
{
var app = new WebApplication("hello", new()
{
AppFolder = "./app"
});
this.Endpoint = app.Endpoint;
}
You can deploy any public Docker image that contains a web application listening to port 80 to a new AKS cluster. Modify the constructor of MyStack
class in Program.cs
file to
public MyStack()
{
var cluster = new AksCluster("demoaks");
var app = new WebApplication("hello", new()
{
Cluster = cluster,
DockerImage = "strm/helloworld-http"
});
this.Endpoint = app.Endpoint;
}
Builds a Docker container from the files in app
folder, push it to Azure Container Registry, and deploy it to a new AKS cluster. Modify the constructor of MyStack
class in Program.cs
file to
public MyStack()
{
var cluster = new AksCluster("demoaks");
var app = new WebApplication("hello", new()
{
Cluster = cluster,
AppFolder = "./app"
});
this.Endpoint = app.Endpoint;
}
To deploy your infrastructure, follow the below steps.
After cloning this repo and making adjustments as described above, from this working directory, run these commands:
-
Create a new stack, which is an isolated deployment target for this example:
$ pulumi stack init dev
-
Login to Azure CLI (you will be prompted to do this during deployment if you forget this step):
$ az login
-
Set the Azure region location to use:
$ pulumi config set azure-native:location westus2
-
Stand up the application by invoking pulumi
$ pulumi up
-
Once you've finished experimenting, tear down your stack's resources by destroying and removing it:
$ pulumi destroy --yes $ pulumi stack rm --yes