Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building a Machine Catalog - Azure Compute Gallery image not found #58

Closed
TimBennett13 opened this issue Apr 10, 2024 · 9 comments · Fixed by #61
Closed

Building a Machine Catalog - Azure Compute Gallery image not found #58

TimBennett13 opened this issue Apr 10, 2024 · 9 comments · Fixed by #61
Labels
enhancement New feature or request

Comments

@TimBennett13
Copy link

TimBennett13 commented Apr 10, 2024

Hello,
I just started using Terraform to build Machine Catalogs for Citrix DaaS in Azure. When i run terraform apply i get this error. I have tried various version names with no results.

citrix_machine_catalog.dev-MyTerraform-MC: Creating... ╷ │ Error: Error creating Machine Catalog │ │ with citrix_machine_catalog.dev-MyTerraform-MC, │ on Main.tf line 17, in resource "citrix_machine_catalog" "dev-MyTerraform-MC": │ 17: resource "citrix_machine_catalog" "dev-MyTerraform-MC" { │ │ Failed to locate Azure Image Gallery image of version 1.0.2 in gallery RIT_CTX_SAFE2_Prod_Image_EastUS_CG, error: could not find resource

The Terraform code is
`terraform {
required_providers {
citrix = {
source = "citrix/citrix"
version = ">=0.5.4"
}
azurerm = {
source = "azurerm"
version = ">= 3.98.0"
}
}
}

MCS Catalog

resource "citrix_machine_catalog" "dev-MyTerraform-MC" {
name = "dev-MyTerraform-MC"
description = "development single-session catalog on Azure hypervisor"
zone = "xxxxxxxxxxxxxx"
allocation_type = "Random"
session_support = "SingleSession"
is_power_managed = true
is_remote_pc = false
provisioning_type = "MCS"
provisioning_scheme = {
hypervisor = "xxxxxxxxxxxxxx"
hypervisor_resource_pool = "xxxxxxxxxxxxxx"
identity_type = "ActiveDirectory"
machine_domain_identity = {
domain = "mydomain"
service_account = "admin"
service_account_password = "mypw"
}
azure_machine_config = {
storage_type = "Standard_LRS"
resource_group = "MyRG-ImageManagement-EastUS-RG"
vda_resource_group = "MyRG-Desktops-EastUS-RG"
use_managed_disks = true
service_offering = "Standard_D2_v2"
gallery_image = {
gallery = "RIT_CTX_SAFE2_Prod_Image_EastUS_CG"
definition = "SAFE2.0-0228-W10-22H2"
version = "1.0.2"
}
Machine_profile = {
machine_profile_resource_group = "MyRG-ImageManagement-EastUS-RG"
machine_profile_vm_name = "MyVMImageProfile"
}
writeback_cache = {
wbc_disk_storage_type = "StandardSSD_LRS"
persist_wbc = false
persist_os_disk = true
persist_vm = false
writeback_cache_disk_size_gb = 16
writeback_cache_memory_size_mb = 1024
storage_cost_saving = false
}
}
network_mapping = {
network_device = "0"
network = "AZ-MyRG-PROD-RG-CIDR"
}
availability_zones = ""
number_of_total_machines = 1
machine_account_creation_rules ={
naming_scheme = "DEV##"
naming_scheme_type ="Numeric"
}
}
}`

I look forward to your reply.

thanks,
Tim

@zhuolun-citrix
Copy link
Collaborator

Hi @TimBennett13 ,

Thank you for bringing this to our attention. Can you please check if the gallery is in the same resource group that you specified in provisioning_scheme.azure_machine_config.resource_group?

After reviewing the code, we realized that if the gallery is not within the resource group you specified for the provisioning scheme, it will not be resolved properly. We will mark this as a bug regardless.

Thank you,
Zhuolun

@zhuolun-citrix zhuolun-citrix added the bug Something isn't working label Apr 10, 2024
@TimBennett13
Copy link
Author

zhuolun,
Thank you for your quick reply. Yes the image gallery is in the same RG specified in the provisioning_scheme.azure_machine_config.resource_group.
Using the code above:
In the azure_machine_config section, the computer gallery , "RIT_CTX_SAFE2_Prod_Image_EastUS_CG", is in the RG "MyRG-ImageManagement-EastUS-RG"

azure_machine_config = {
storage_type = "Standard_LRS"
resource_group = "MyRG-ImageManagement-EastUS-RG"
vda_resource_group = "MyRG-Desktops-EastUS-RG"
use_managed_disks = true
service_offering = "Standard_D2_v2"
gallery_image = {
gallery = "RIT_CTX_SAFE2_Prod_Image_EastUS_CG"
definition = "SAFE2.0-0228-W10-22H2"
version = "1.0.2"
}
Machine_profile = {
machine_profile_resource_group = "MyRG-ImageManagement-EastUS-RG"
machine_profile_vm_name = "MyVMImageProfile"
}

Thanks,
Tim

@zhuolun-citrix
Copy link
Collaborator

zhuolun-citrix commented Apr 10, 2024

Hi @TimBennett13

After further debugging we just realized that the schema intended as the resource_group field is specifically for locating the gallery, which means that it's not really a bug but as designed.

I have also debugged with my own setup of image gallery and it worked fine. Could you please perform an IAM check to make sure that the Azure service account you used for creating the hypervisor has permission to access the image gallery and the image definitions?

Thank you.

@TimBennett13
Copy link
Author

I checked and the Azure service principal used for the Hosting Connection has a role of contributor on the ImageManagement-EastUS-RG Resource Group that the Compute gallery resides in.
If it matters, we are using a multiple subscription model where the core infrastructure including the compute gallery is in one subscription and the VDA's are in different subscriptions. The Hosting connection does not connect to the core subscription but connects to the VDA subscription and the image is visible to the machine catalog because of the role set for the Azure Service Principal on the Image catalog in the ImageManagement-EastUS-RG Resource Group.

Thanks,
Tim

@TimBennett13
Copy link
Author

Hello again. To troubleshoot I created a storage account and uploaded a vhd. Then changed the script to using the vhd.

resource_group = "MyCoreSub-ImageManagement-EastUS-RG"
/# using blob for image instead of gallery
storage_account = "terraformtroubleshooting"
container = "mcsvhd"
master_image = "mcs-master.vhd"

This failed saying it could not find the vhd. Then i moved the storage account to the VDA Resource Group that is in the sub defined in the Hosting Connection (the VDA subscription) and it found the vhd and started building the MC.

resource_group = "MyVDASub-ImageManagement-EastUS-RG"
/# using blob for image instead of gallery
storage_account = "terraformtroubleshooting"
container = "mcsvhd"
master_image = "mcs-master.vhd"

If it helps, in DaaS Studio when I get to the image selection point in creating a machine catalog i am presented with the option to choose the subscription where I can choose the core sub and can see the compute gallery. This is facilitated by adding a role for the Azure Service Principal to the image Resource Group in the core subscription.

Thanks,
Tim

@zhuolun-citrix
Copy link
Collaborator

Hi @TimBennett13 ,

Looks like this is a use case that we have not supported in our Terraform Provider yet. We will mark this as enhancement instead and will work on supporting this in the next release.

Thank you very much for bring this to our attention.

Zhuolun

@zhuolun-citrix zhuolun-citrix added enhancement New feature or request and removed bug Something isn't working labels Apr 12, 2024
@TimBennett13
Copy link
Author

TimBennett13 commented Apr 15, 2024 via email

@zhuolun-citrix
Copy link
Collaborator

@TimBennett13 ,

We will publish a new version in ~2 weeks from now.

Please stay tuned.

Thank you.

@j7lloyd
Copy link

j7lloyd commented Apr 16, 2024

@zhuolun-citrix, excellent news! Out of interest, will any of the enhancements proposed in the 2 open PRs be included, too?

@aneeshk-citrix aneeshk-citrix linked a pull request Apr 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants