Unable to Run custom script in linux servers using terraform

I am able to build vnet/subnet/vm. but unable to run custom script in linux vm using terraform code. after running the apply command it lefts only custom script part. I would request , please help me.

**######Provider file######**
[root@master devops1]# cat provider.tf
terraform {

  required_version = ">=0.12"

  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "~>2.0"
    }
  }
}

provider "azurerm" {
  features {}
}
**###### Main.tf############**
# Reference existing resource group
data "azurerm_resource_group" "main" {
     name = "devops-rg"
}

# Reference existing vnet
data "azurerm_virtual_network" "main" {
    name                = "devops-network"
    resource_group_name = data.azurerm_resource_group.main.name
}

# Reference existing subnet
data "azurerm_subnet" "main" {
    name                = "devops-subnet"
    virtual_network_name = data.azurerm_virtual_network.main.name
    resource_group_name = data.azurerm_resource_group.main.name
}

# Create network interface
resource "azurerm_network_interface" "main" {
    name                      = "machine1-nic"
    location                  = "West Europe"
    resource_group_name       = data.azurerm_resource_group.main.name

    ip_configuration {
        name                          = "machine1-ip"
        subnet_id                     = data.azurerm_subnet.main.id
        private_ip_address_allocation = "Dynamic"
            }

    tags = {
        environment = "Devops"
    }
}

# Data template Bash bootstrapping file
#data "template_file" "linux-vm-cloud-init" {
#  template = file("machine1-data.sh")
#}

#Create CentOS 7.5 virtual machince
resource "azurerm_linux_virtual_machine" "main" {
    name                  = "machine1"
    location              = "West Europe"
    resource_group_name   = data.azurerm_resource_group.main.name
    network_interface_ids = [azurerm_network_interface.main.id]
    size                  = "Standard_DS1_v2"

    os_disk {
        name              = "machine1disk"
        caching           = "ReadWrite"
        storage_account_type = "Standard_LRS"
    }

    source_image_reference {
        publisher = "OpenLogic"
        offer     = "CentOS"
        sku       = "7.5"
        version   = "latest"
    }
    computer_name  = "machine1"
    admin_username = "user"
    admin_password = "Password@1234567"
  **custom_data = filebase64("machine1-data.sh")**
    disable_password_authentication = false

    tags = {
        environment = "Devops"
    }
}
}

Bash script is

#! /bin/sh
#sudo yum update -y
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
echo "<h1>Azure Virtual Machine(Machine1) deployed with Terraform</h1>" | sudo tee /var/www/html/index.html

I would appriciate if any one can help. wanted to know, how will call bash script in terraform to complete the post build activity in linux servers.

Actually, I am beginner in terraform