AZURE RHEL BYOS VMMarketplaceInvalidInput Error

I am having problem with AZURE Redhats BYOS Gold image and getting it to work. I can build with the Market place Version with no problem so I know the whole template is good.

But when I change to the RHEL provided image

  image_publisher                                  = "RedHat"
  image_offer                                      = "rhel-byos"
  image_sku                                        = "rhel-lvm78-gen2"

I get teh following VMMarketPlaceInvalidInput Error. And I am at a loss of what I am doing wrong

Details=[
{"code":"Conflict","message":"{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    
\"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        
\"code\": \"VMMarketplaceInvalidInput\",\r\n       

 \"message\": \"Creating a virtual machine from Marketplace image or a custom image sourced from a Marketplace image requires Plan information in the request. VM: '/subscriptions/XXXXXXXX-XXXXX-XXXXXX-XXXXX-XXXXXXXXXXXXX/resourceGroups/YY-YY-YYYYY-YYY-YYYY/providers/Microsoft.Compute/virtualMachines/rhel-packer-image-builder-20210108t202236'.\"\r\n      }\r\n    ]\r\n  }\r\n}"}]

I went to Redhats Cloud Resource and Enabled the RHEL Gold Images and I can see the “Offers”

az vm image list --publisher RedHat --offer rhel-byos -s rhel-lvm78-gen2 --all -o table 
Offer      Publisher    Sku              Urn                                            Version
---------  -----------  ---------------  ---------------------------------------------  ------------
rhel-byos  RedHat       rhel-lvm78-gen2  RedHat:rhel-byos:rhel-lvm78-gen2:7.8.20200715  7.8.20200715
rhel-byos  RedHat       rhel-lvm78-gen2  RedHat:rhel-byos:rhel-lvm78-gen2:7.8.20200824  7.8.20200824
rhel-byos  RedHat       rhel-lvm78-gen2  RedHat:rhel-byos:rhel-lvm78-gen2:7.8.20201222  7.8.20201222

here is the whole template I wrap it with ansible so there is nothing that I have changed other then the image_publisher offer and sku

source "azure-arm" "autogenerated_1" {
  client_id       = "{{ azure_client_id }}"
  client_secret   = "{{ azure_client_secret }}"
  subscription_id = "{{ azure_subscription_id }}"
  tenant_id       = "{{ azure_tenant_id }}"

  build_resource_group_name                        = "{{ build_rg_name }}"
  image_publisher                                  = "RedHat"
  image_offer                                      = "rhel-byos"
  image_sku                                        = "rhel-lvm78-gen2"
  managed_image_name                               = "{{ publish_image_name }}_{{ ansible_date_time.iso8601_basic_short | lower}}"
  managed_image_os_disk_snapshot_name              = "snapshot_{{ publish_image_name }}_{{ ansible_date_time.iso8601_basic_short| lower }}"
  managed_image_resource_group_name                = "{{ build_rg_name }}"
  os_type                                          = "Linux"
  private_virtual_network_with_public_ip           = "false"
  shared_gallery_image_version_exclude_from_latest = "{{ publish_exclude_from_latest | lower }}"
  shared_image_gallery_timeout                     =  "{{ build_timeout_minute }}m"
  shared_image_gallery_destination {
    gallery_name        = "{{ publish_gallery_name }}"
    image_name          = "{{ publish_image_name }}"
    image_version       = "{{ version_major }}.{{ version_minor }}.{{ version_build }}"
    replication_regions = ["{{ build_location }}"]
    resource_group      = "{{  publish_rg_name }}"
    subscription        = "{{ azure_subscription_id }}"
  }
  temp_compute_name    = "rhel-packer-image-builder-{{ ansible_date_time.iso8601_basic_short| lower }}"
  virtual_network_name = "{{ build_vm_network }}"
  virtual_network_subnet_name = "{{ build_vm_subnet }}"
  vm_size              = "{{ build_vm_size }}"
}

build {
  sources = ["source.azure-arm.autogenerated_1"]

  provisioner "ansible" {
    ansible_env_vars = ["ANSIBLE_TIMEOUT=30", 
                        "ANSIBLE_HOST_KEY_CHECKING=False", 
                        "ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=15m'", 
                        "ANSIBLE_NOCOLOR=True"]
    extra_arguments  = ["--skip-tags", "restart","--diff"]
    playbook_file    = "build-ansible/playbook.yml"
  }
  post-processor "manifest" {
      output = "manifest.json"
      strip_path = true
      custom_data = {
        version = "{{ version_major }}.{{ version_minor }}.{{ version_build }}"
      }
  }
}

Did you try adding the plan details?

I did try plan_info sorry forgot to mention that. same issue,

I am currently looking at “Licensing issues” with out cloud team. THis might be the real issue

Seems that while the error is not the same from Packer, it would make sense as a simular issue.

az vm create -n rhel-byos-vm -g rg-ent-imgbuilder-cus-prod --image redhat:rhel-byos:rhel-lvm8:latest --validate

Azure Error: MarketplacePurchaseEligibilityFailed
Message: Marketplace purchase eligibilty check returned errors. See inner errors for details. 
Exception Details:
Error Code: BadRequest
Message: Offer with PublisherId: 'redhat', OfferId: 'rhel-byos' cannot be purchased due `to validation errors. For more information see details. Correlation Id: 'XXXXXXXX-XXXXX-XXXXXX-XXXX-XXXXXX' You have not accepted the legal terms on this subscription: 'XXXXXXXXX-XXXXX-XXXXX-XXXX-XXXXXXXXXXXX' for this plan. Before the subscription can be used, you need to accept the legal terms of the image. To read and accept legal terms, use the Azure CLI commands described at https://go.microsoft.com/fwlink/?linkid=2110637 or the PowerShell commands available at https://go.microsoft.com/fwlink/?linkid=862451. Alternatively, deploying via the Azure portal provides a UI experience for reading and accepting the legal terms. Offer details: publisher='redhat' offer = 'rhel-byos', sku = 'rhel-lvm8', Correlation Id: 'XXXXXXXXX-XXXXX-XXXXX-XXXXXX-XXXXXXXXXXX'.[{"You have not accepted the legal terms on this subscription: 'XXXXXXXX-XXXXX-XXXXX-XXXX-XXXXXXXXXXX' for this plan. Before the subscription can be used, you need to accept the legal terms of the image. To read and accept legal terms, use the Azure CLI commands described at https://go.microsoft.com/fwlink/?linkid=2110637 or the PowerShell commands available at https://go.microsoft.com/fwlink/?linkid=862451. Alternatively, deploying via the Azure portal provides a UI experience for reading and accepting the legal terms. Offer details: publisher='redhat' offer = 'rhel-byos', sku = 'rhel-lvm8', Correlation Id: 'XXXXXX-XXXXX-4c4c-XXXXX-XXXXXXXXX'.":"StoreApi"}]`

I have opened an Issue on this. I got though the problem by accepting the market license and that solved some problems

but now I am getting

An argument named "plan_info" is not expected here. Did you mean to define a
block of type "plan_info"?
  (source code not available)
An argument named "plan_info" is not expected here. Did you mean to define a
block of type "plan_info"?
source "azure-arm" "autogenerated_1" {
  plan_info = {
    plan_name      = "rhel-lvm78-gen2"
    plan_product   = "rhel-byos"
    plan_publisher = "redhat"
  }
  build_resource_group_name = "rg"
  subscription_id                        = "XXXXX-XXXX-XXXX-XXXX-XXXXXXXX"
  tenant_id                              = "XXXXX-XXXX-XXXXX-XXXXX-XXXXXXXXXXXXXXX"
  image_publisher                        = "RedHat"
  image_offer                            = "rhel-byos"
  image_sku                              = "rhel-lvm78-gen2"
  <<<<<THE REST DELETED>>>>>>>

OK it was a syntax issue, with all the other issues I was having I must have missed this iterative update

  plan_info  {
    plan_name      = "rhel-lvm78-gen2"
    plan_product   = "rhel-byos"
    plan_publisher = "redhat"
  }