Packer hyperv-iso fails to boot up after cloud-init rebooting

I am trying to build an image using packer. It’s able to set up everything correctly and ran the cloud init using the user-data file I provided. After setting up everything it reboots, and that’s where the problem is. It fails and gives me an error saying I need to provide a boot device.
Can someone tell me what I am missing in my packer script or the user-data script that is causing this?

Here is my packer script:

source "hyperv-iso" "ubuntu-focal-griffin" {
  # Booting
  boot_command = [
    "/casper/vmlinuz ",
    "initrd=/casper/initrd ",
    "autoinstall ",
  shutdown_command = "echo 'ubuntu' | sudo -S -E shutdown -P now"
  shutdown_timeout = "15m"
  boot_wait = "5s"
  vm_name = local.ami_name
  cpus = "2"
  memory = "4000"
  disk_block_size = "1"
  disk_size = "50000"
  switch_name = "MySwitch"
  output_directory = "./IMAGE_FILES"
  iso_urls = [
  iso_checksum = "28ccdb56450e643bad03bb7bcf7507ce3d8d90e8bf09e38f6bd9ac298a98eaad"
  cd_label = "cidata"
  cd_files = [

  # SSH Settings
  ssh_username = "ubuntu"
  ssh_password = "ubuntu"
  ssh_timeout = "30m"


  version: 1
    # otherwise packer tries to connect and exceed max attempts:
    - sudo systemctl stop ssh
  packages: [open-vm-tools, openssh-server, net-tools, perl, open-iscsi, ntp, curl, vim, ifupdown, zip, unzip, gnupg2, software-properties-common, apt-transport-https, ca-certificates, lsb-release, python3-pip, jq]
    hostname: test
    username: test
    password: 'test'
    install-server: true
    - echo 'test ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/test
    - curtin in-target --target=/target -- chmod 440 /etc/sudoers.d/test
    - curtin in-target --target=/target -- apt-get update
    - curtin in-target --target=/target -- apt-get upgrade --yes


can someone help with this issue?