Assistance Needed with Setting Up and Running infra.sh Script

Hello Team,

I need help with setting up and navigating the infrastructure script named infra.sh located in the /root directory. Here’s what I’m trying to do:

  1. Navigate to the /root directory.
  2. Confirm that the infra.sh script is present.
  3. Run the script to complete the infrastructure setup.

Could someone guide me or assist in completing this task? Please let me know the steps or actions needed.

Thank you so much for your support!
Best regards,

I assume this is from a lab. If you can please include a link to that lab, we can look it over.

https://learn.kodekloud.com/user/courses/az-104-microsoft-azure-administrator/module/50248c52-4b17-4c2d-87f8-52a42eff2d2f/lesson/2fc7374a-2d09-4449-91cd-9ab8d83aea60

Hey! I’m also facing issues w.r.t this task especially with executing the infra.sh script.

Please look into the script execution output - which is failing mid way during the vm webserver-02 creation.

~ ➜  bash infra.sh


 Adding subnet configuration...

{
  "newVNet": {
    "addressSpace": {
      "addressPrefixes": [
        "10.0.0.0/16"
      ]
    },
    "enableDdosProtection": false,
    "etag": "W/\"29813ab1-88fc-43ac-abb0-2f86cbaa8565\"",
    "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet",
    "location": "eastus",
    "name": "kk-persistent-vnet",
    "privateEndpointVNetPolicies": "Disabled",
    "provisioningState": "Succeeded",
    "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
    "resourceGuid": "169d033f-91c3-4377-935a-2906b5654bce",
    "subnets": [
      {
        "addressPrefix": "10.0.1.0/24",
        "delegations": [],
        "etag": "W/\"29813ab1-88fc-43ac-abb0-2f86cbaa8565\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet/subnets/jumpboxSubnet",
        "name": "jumpboxSubnet",
        "privateEndpointNetworkPolicies": "Disabled",
        "privateLinkServiceNetworkPolicies": "Enabled",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "type": "Microsoft.Network/virtualNetworks/subnets"
      }
    ],
    "type": "Microsoft.Network/virtualNetworks",
    "virtualNetworkPeerings": []
  }
}
{
  "addressPrefix": "10.0.2.0/24",
  "delegations": [],
  "etag": "W/\"0d6dd67d-e654-4684-ac0a-66f48f5b6fc9\"",
  "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet/subnets/webSubnet",
  "name": "webSubnet",
  "privateEndpointNetworkPolicies": "Disabled",
  "privateLinkServiceNetworkPolicies": "Enabled",
  "provisioningState": "Succeeded",
  "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
  "type": "Microsoft.Network/virtualNetworks/subnets"
}


 Creating network security group and rule...

{
  "NewNSG": {
    "defaultSecurityRules": [
      {
        "access": "Allow",
        "description": "Allow inbound traffic from all VMs in VNET",
        "destinationAddressPrefix": "VirtualNetwork",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Inbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/AllowVnetInBound",
        "name": "AllowVnetInBound",
        "priority": 65000,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "VirtualNetwork",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      },
      {
        "access": "Allow",
        "description": "Allow inbound traffic from azure load balancer",
        "destinationAddressPrefix": "*",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Inbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/AllowAzureLoadBalancerInBound",
        "name": "AllowAzureLoadBalancerInBound",
        "priority": 65001,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "AzureLoadBalancer",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      },
      {
        "access": "Deny",
        "description": "Deny all inbound traffic",
        "destinationAddressPrefix": "*",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Inbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/DenyAllInBound",
        "name": "DenyAllInBound",
        "priority": 65500,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "*",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      },
      {
        "access": "Allow",
        "description": "Allow outbound traffic from all VMs to all VMs in VNET",
        "destinationAddressPrefix": "VirtualNetwork",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Outbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/AllowVnetOutBound",
        "name": "AllowVnetOutBound",
        "priority": 65000,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "VirtualNetwork",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      },
      {
        "access": "Allow",
        "description": "Allow outbound traffic from all VMs to Internet",
        "destinationAddressPrefix": "Internet",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Outbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/AllowInternetOutBound",
        "name": "AllowInternetOutBound",
        "priority": 65001,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "*",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      },
      {
        "access": "Deny",
        "description": "Deny all outbound traffic",
        "destinationAddressPrefix": "*",
        "destinationAddressPrefixes": [],
        "destinationPortRange": "*",
        "destinationPortRanges": [],
        "direction": "Outbound",
        "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/defaultSecurityRules/DenyAllOutBound",
        "name": "DenyAllOutBound",
        "priority": 65500,
        "protocol": "*",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "sourceAddressPrefix": "*",
        "sourceAddressPrefixes": [],
        "sourcePortRange": "*",
        "sourcePortRanges": [],
        "type": "Microsoft.Network/networkSecurityGroups/defaultSecurityRules"
      }
    ],
    "etag": "W/\"50718c27-7930-4830-88b5-f617418e2a2c\"",
    "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg",
    "location": "eastus",
    "name": "kk-persistent-nsg",
    "provisioningState": "Succeeded",
    "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
    "resourceGuid": "99330f0e-3f9e-4865-b3d5-7d84942809b2",
    "securityRules": [],
    "type": "Microsoft.Network/networkSecurityGroups"
  }
}
{
  "access": "Allow",
  "destinationAddressPrefix": "*",
  "destinationAddressPrefixes": [],
  "destinationPortRange": "80",
  "destinationPortRanges": [],
  "direction": "Inbound",
  "etag": "W/\"e7e7ea4d-48a5-4f35-b44b-fd1226750869\"",
  "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg/securityRules/http-allow",
  "name": "http-allow",
  "priority": 100,
  "protocol": "Tcp",
  "provisioningState": "Succeeded",
  "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
  "sourceAddressPrefix": "Internet",
  "sourceAddressPrefixes": [],
  "sourcePortRange": "*",
  "sourcePortRanges": [],
  "type": "Microsoft.Network/networkSecurityGroups/securityRules"
}


 Associating NSG with webSubnet...

{
  "addressPrefix": "10.0.2.0/24",
  "delegations": [],
  "etag": "W/\"8c707558-17ef-4bee-be59-afc01a9eec4b\"",
  "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet/subnets/webSubnet",
  "name": "webSubnet",
  "networkSecurityGroup": {
    "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkSecurityGroups/kk-persistent-nsg",
    "resourceGroup": "kml_rg_main-fb4c2b10dedd454f"
  },
  "privateEndpointNetworkPolicies": "Disabled",
  "privateLinkServiceNetworkPolicies": "Enabled",
  "provisioningState": "Succeeded",
  "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
  "type": "Microsoft.Network/virtualNetworks/subnets"
}


 Creating availability set...

{
  "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Compute/availabilitySets/kk-persistent-availabilityset",
  "location": "eastus",
  "name": "kk-persistent-availabilityset",
  "platformFaultDomainCount": 3,
  "platformUpdateDomainCount": 3,
  "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
  "sku": {
    "name": "Aligned"
  },
  "tags": {},
  "type": "Microsoft.Compute/availabilitySets",
  "virtualMachines": []
}

 Creating NIC named webserver-01-nic for VM named webserver-01...

{
  "NewNIC": {
    "auxiliaryMode": "None",
    "auxiliarySku": "None",
    "disableTcpStateTracking": false,
    "dnsSettings": {
      "appliedDnsServers": [],
      "dnsServers": [],
      "internalDomainNameSuffix": "h2bz0fwdsf1uhe00fedlkzklzg.bx.internal.cloudapp.net"
    },
    "enableAcceleratedNetworking": false,
    "enableIPForwarding": false,
    "etag": "W/\"8b553765-8e6d-4b16-8854-187964c49b1e\"",
    "hostedWorkloads": [],
    "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkInterfaces/webserver-01-nic",
    "ipConfigurations": [
      {
        "etag": "W/\"8b553765-8e6d-4b16-8854-187964c49b1e\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkInterfaces/webserver-01-nic/ipConfigurations/ipconfig1",
        "name": "ipconfig1",
        "primary": true,
        "privateIPAddress": "10.0.2.4",
        "privateIPAddressVersion": "IPv4",
        "privateIPAllocationMethod": "Dynamic",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "subnet": {
          "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet/subnets/webSubnet",
          "resourceGroup": "kml_rg_main-fb4c2b10dedd454f"
        },
        "type": "Microsoft.Network/networkInterfaces/ipConfigurations"
      }
    ],
    "location": "eastus",
    "name": "webserver-01-nic",
    "nicType": "Standard",
    "provisioningState": "Succeeded",
    "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
    "resourceGuid": "e7c6d84e-ac2e-4390-bca4-13fdf795dc69",
    "tapConfigurations": [],
    "type": "Microsoft.Network/networkInterfaces",
    "vnetEncryptionSupported": false
  }
}

 Creating VM named webserver-01 in availability set...

The default value of '--size' will be changed to 'Standard_D2s_v5' from 'Standard_DS1_v2' in a future release.
{
  "fqdns": "",
  "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Compute/virtualMachines/webserver-01",
  "location": "eastus",
  "macAddress": "60-45-BD-A7-17-E5",
  "powerState": "VM running",
  "privateIpAddress": "10.0.2.4",
  "publicIpAddress": "",
  "resourceGroup": "kml_rg_main-fb4c2b10dedd454f"
}

 Creating NIC named webserver-02-nic for VM named webserver-02...

{
  "NewNIC": {
    "auxiliaryMode": "None",
    "auxiliarySku": "None",
    "disableTcpStateTracking": false,
    "dnsSettings": {
      "appliedDnsServers": [],
      "dnsServers": [],
      "internalDomainNameSuffix": "h2bz0fwdsf1uhe00fedlkzklzg.bx.internal.cloudapp.net"
    },
    "enableAcceleratedNetworking": false,
    "enableIPForwarding": false,
    "etag": "W/\"1bb4a870-acb4-4b38-9172-4e0db77ebb22\"",
    "hostedWorkloads": [],
    "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkInterfaces/webserver-02-nic",
    "ipConfigurations": [
      {
        "etag": "W/\"1bb4a870-acb4-4b38-9172-4e0db77ebb22\"",
        "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/networkInterfaces/webserver-02-nic/ipConfigurations/ipconfig1",
        "name": "ipconfig1",
        "primary": true,
        "privateIPAddress": "10.0.2.5",
        "privateIPAddressVersion": "IPv4",
        "privateIPAllocationMethod": "Dynamic",
        "provisioningState": "Succeeded",
        "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
        "subnet": {
          "id": "/subscriptions/a2b28c85-1948-4263-90ca-bade2bac4df4/resourceGroups/kml_rg_main-fb4c2b10dedd454f/providers/Microsoft.Network/virtualNetworks/kk-persistent-vnet/subnets/webSubnet",
          "resourceGroup": "kml_rg_main-fb4c2b10dedd454f"
        },
        "type": "Microsoft.Network/networkInterfaces/ipConfigurations"
      }
    ],
    "location": "eastus",
    "name": "webserver-02-nic",
    "nicType": "Standard",
    "provisioningState": "Succeeded",
    "resourceGroup": "kml_rg_main-fb4c2b10dedd454f",
    "resourceGuid": "ba29b875-e440-4544-9e2d-2f0ec1b1f4c7",
    "tapConfigurations": [],
    "type": "Microsoft.Network/networkInterfaces",
    "vnetEncryptionSupported": false
  }
}

 Creating VM named webserver-02 in availability set...

The default value of '--size' will be changed to 'Standard_D2s_v5' from 'Standard_DS1_v2' in a future release.
Availability set 'kk-persistent-availabilityset' does not exist.
Failed to create VM webserver-02

I assume that by running this script, the infra must be provisioned accordingly without any issues. Please let me know if there’s anything I need to change from my end for the completion of this task.