Slide 1

Slide 1 text

Build Your Azure Infrastructure as Code With .NET Core Hossam Barakat Technical Lead at Willow @hossambarakat_ | www.hossambarakat.net

Slide 2

Slide 2 text

@hossambarakat_ Data Centers

Slide 3

Slide 3 text

@hossambarakat_ Rise of Cloud Computing

Slide 4

Slide 4 text

@hossambarakat_ How to provision cloud resources?

Slide 5

Slide 5 text

@hossambarakat_ Manual AKA Point and Click

Slide 6

Slide 6 text

@hossambarakat_ Manual AKA Point and Click

Slide 7

Slide 7 text

@hossambarakat_ Snowflake Servers

Slide 8

Slide 8 text

@hossambarakat_ Infrastructure as Code

Slide 9

Slide 9 text

@hossambarakat_ • Managing and provisioning cloud resources using code. Infrastructure as Code

Slide 10

Slide 10 text

@hossambarakat_ Imperative: CLI commands and scripts

Slide 11

Slide 11 text

@hossambarakat_ Idempotency and error handling

Slide 12

Slide 12 text

@hossambarakat_ Declarative Infrastructure as Code

Slide 13

Slide 13 text

@hossambarakat_ Tool Declarative Infrastructure as Code Desired State Actual Resources

Slide 14

Slide 14 text

@hossambarakat_ • Azure Resource Manager • Terraform • Bicep • AWS CloudFormation • Google Deployment Manager • … Declarative Infrastructure as Code tools

Slide 15

Slide 15 text

@hossambarakat_ • JSON, YAML, domain specific languages (DSLs),… Infrastructure as Code tools

Slide 16

Slide 16 text

@hossambarakat_

Slide 17

Slide 17 text

@hossambarakat_ Enter Pulumi

Slide 18

Slide 18 text

@hossambarakat_ • Pulumi is an open source infrastructure as code tool the lets you use real languages – C#, TypeScript, Go,… – to provision and manage cloud resources. What is Pulumi?

Slide 19

Slide 19 text

@hossambarakat_ • Control flow with loops and if conditions • Abstraction with functions, classes, packages,… • Code sharing with package management (Nuget, npm,…) • Authoring with favourite IDEs, refactoring, code completion, static type checking • Testing with existing frameworks and tools Benefits

Slide 20

Slide 20 text

@hossambarakat_

Slide 21

Slide 21 text

@hossambarakat_ Terraform vs Pulumi var resourceGroup = new ResourceGroup("pulumi-resources", new ResourceGroupArgs { Location = " Australia East" }); ); var environments = new string[]{"dev", "uat", "prod"}; foreach (var environment in environments) { var storageAccount = new StorageAccount( $"storage{environment}", new StorageAccountArgs { ResourceGroupName = resourceGroup.Name, Location = resourceGroup.Location, Sku = new SkuArgs{ Name = SkuName.Standard_LRS }, AccessTier = AccessTier.Hot }); } resource "azurerm_resource_group" "rg" { name = "terraform-resources" location = ”Australia East" } variable "environments" { description = "storage account regions" type = list(string) default = ["dev", "uat", "prod"] } resource "azurerm_storage_account" "sa" { name = "iacpulumi${var.environments[count.index]}" resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location account_tier = "Standard" account_replication_type = "LRS" count = length(var.environments) }

Slide 22

Slide 22 text

@hossambarakat_ Pulumi Fundamentals

Slide 23

Slide 23 text

@hossambarakat_ Projects & Stacks web-app (Pulumi.yaml) Project $ pulumi new Stacks $ pulumi stack init stackName Pulumi..yaml Pulumi.yaml

Slide 24

Slide 24 text

@hossambarakat_ Configurations $ pulumi config set dbPassword S3cr37 config: serverless-app:dbPassword: S3cr37 Pulumi..yaml var config = new Pulumi.Config(); var password = config.Require("dbPassword"); Pulumi.cs

Slide 25

Slide 25 text

@hossambarakat_ Secrets $ pulumi config set --secret dbPassword S3cr37 var config = new Pulumi.Config(); var password = config.Require("dbPassword"); Pulumi.cs Pulumi..yaml config: serverless-app:dbPassword: secure: AAABAELDrCQE+rQbzTxN43iAD6iGDXTYQ90AzpILkfEY3uwtc+g=

Slide 26

Slide 26 text

@hossambarakat_ Application architecture on Azure

Slide 27

Slide 27 text

@hossambarakat_

Slide 28

Slide 28 text

@hossambarakat_ But that would be imperative, right?

Slide 29

Slide 29 text

@hossambarakat_ How Pulumi Works State CLI and Engine AWS Azure Kubernetes Providers Code Plan Apply new Resource()

Slide 30

Slide 30 text

@hossambarakat_ Continuous Deployment Infrastructure as Code Manual Review State

Slide 31

Slide 31 text

@hossambarakat_ GitHub Integration

Slide 32

Slide 32 text

@hossambarakat_ Testing Unit Testing Integration Testing

Slide 33

Slide 33 text

@hossambarakat_ Unit Testing

Slide 34

Slide 34 text

@hossambarakat_ Summary

Slide 35

Slide 35 text

@hossambarakat_

Slide 36

Slide 36 text

@hossambarakat_ • https://github.com/hossambarakat/pulumi-demos • http://pulumi.com/docs • https://github.com/pulumi/examples Resources https://bit.ly/pulumi-ndc-porto

Slide 37

Slide 37 text

@hossambarakat_ Questions?

Slide 38

Slide 38 text

Thanks Hossam Barakat @hossambarakat_ www.hossambarakat.net