Hello everyone, I created AVD hostpool with approp...
# python
b
Hello everyone, I created AVD hostpool with appropriate registration token (created token trough code), now i'm trying to retrieve that token so i can join client virtual machine to the hostpool. How i can read that registration from resource that i created(host pool)? When i read hostpool property named registration info, i always receive "None" value, even though token is created and visible on azure portal. I'm using Python and everything is deployed in single stack. Code for creation is following: host_pool = azure_native.desktopvirtualization.HostPool( resource_name = f"vdpool-{dt_map.project_name}-{dt_map.name}", resource_group_name=resource_group.name, location=resource_group.location, host_pool_type="Pooled", load_balancer_type="BreadthFirst", max_session_limit=3, preferred_app_group_type="Desktop", custom_rdp_property="drivestoredirects;audiomodei0;videoplaybackmodei1;redirectclipboardi0;redirectprintersi0;devicestoredirects;redirectcomportsi0;redirectsmartcardsi0;usbdevicestoredirects;enablecredsspsupporti1;use multimoni1;audiocapturemodei0;encode redirected video capturei1;redirected video capture encoding qualityi0;camerastoredirects", registration_info=azure_native.desktopvirtualization.RegistrationInfoArgs( expiration_time=(datetime.utcnow() + timedelta(hours=2)).isoformat() + 'Z', # 2h from now registration_token_operation=azure_native.desktopvirtualization.RegistrationTokenOperation.UPDATE ), opts=pulumi.ResourceOptions( provider=provider) )
l
Ćao Đorđe -- I assume you mean you are trying to access
host_pool.registration_info.token
and it's coming back as
None
? Or is the entier
registration_info
object itself
None
?
b
Hello Will, yes, actually i was trying to access both, just to get something in return, but in both cases i received None value. When i check on portal token exists.. Now i even tried with https request, but i also received None value. At the end i want to get host_pool.registration_info.token value 🙂 Thank you for response
l
OK, and where are you trying to access them? Are you able to share a snippet?
b
I was trying on a lot of places, for example: def create_avd(resource_group, provider, dt_map): host_pool = azure_native.desktopvirtualization.HostPool( resource_name = f"vdpool-{dt_map.project_name}-{dt_map.name}", resource_group_name=resource_group.name, location=resource_group.location, host_pool_type="Pooled", load_balancer_type="BreadthFirst", max_session_limit=3, preferred_app_group_type="Desktop", custom_rdp_property="drivestoredirects;audiomodei0;videoplaybackmodei1;redirectclipboardi0;redirectprintersi0;devicestoredirects;redirectcomportsi0;redirectsmartcardsi0;usbdevicestoredirects;enablecredsspsupporti1;use multimoni1;audiocapturemodei0;encode redirected video capturei1;redirected video capture encoding qualityi0;camerastoredirects", registration_info=azure_native.desktopvirtualization.RegistrationInfoArgs( expiration_time=(datetime.utcnow() + timedelta(hours=2)).isoformat() + 'Z', # 2h from now registration_token_operation=azure_native.desktopvirtualization.RegistrationTokenOperation.UPDATE ), opts=pulumi.ResourceOptions( provider=provider) ) host_pool.registration_info.apply(lambda registration_info: print(f"{registration_info.token}")) Also return value of this function is host_pool resources, so later on i was trying to access it when i'm creating client machine
l
Hm, that looks right to me, but I'm not an expert on Azure Native. It might be worth raising a bug report on the Azure Native provider to see if anyone there can help? I'm curious if it's just this output, or do you see the same behaviour for all outputs e.g.
host_pool.system_data.apply(lambda x: print(x))
or the like?
b
Well, i didn't use it that often for different resources, but it seems to me this one is specific, cuz it always return
None
value. Strange thing is that this https request also returns
None
.
url = f"<https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.DesktopVirtualization/hostPools/{host_pool_name}/retrieveRegistrationToken?api-version=2022-02-10-preview>"
response = requests.post(url)
if response.status_code == 200:
registration_info = response.json()
registration_token = registration_info.get("token")
print(f"Registration Token: {registration_token}")
else:
print(f"Error retrieving registration token: {response.text}")
return registration_token
l
That's interesting. It's likely that the provider is just using that request under the hood, so maybe that request behaves differently that expected, or we need to amend the provider to call it in a different way. Either way I'd be tempted to raise an issue on the provider.