diff --git a/azurerm/internal/services/iothub/data_source_iothub_dps_shared_access_policy.go b/azurerm/internal/services/iothub/data_source_iothub_dps_shared_access_policy.go index 63dc608266c0..af6313f00a37 100644 --- a/azurerm/internal/services/iothub/data_source_iothub_dps_shared_access_policy.go +++ b/azurerm/internal/services/iothub/data_source_iothub_dps_shared_access_policy.go @@ -103,8 +103,8 @@ func dataSourceIotHubDPSSharedAccessPolicyRead(d *schema.ResourceData, meta inte primaryConnectionString := "" secondaryConnectionString := "" - if iothubDps.Properties != nil && iothubDps.Properties.DeviceProvisioningHostName != nil { - hostname := iothubDps.Properties.DeviceProvisioningHostName + if iothubDps.Properties != nil && iothubDps.Properties.ServiceOperationsHostName != nil { + hostname := iothubDps.Properties.ServiceOperationsHostName if primary := accessPolicy.PrimaryKey; primary != nil { primaryConnectionString = getSAPConnectionString(*hostname, keyName, *primary) } diff --git a/azurerm/internal/services/iothub/resource_arm_iothub_dps_shared_access_policy.go b/azurerm/internal/services/iothub/resource_arm_iothub_dps_shared_access_policy.go index 03e2b794b7fe..66f5294b14b7 100644 --- a/azurerm/internal/services/iothub/resource_arm_iothub_dps_shared_access_policy.go +++ b/azurerm/internal/services/iothub/resource_arm_iothub_dps_shared_access_policy.go @@ -236,8 +236,8 @@ func resourceArmIotHubDPSSharedAccessPolicyRead(d *schema.ResourceData, meta int primaryConnectionString := "" secondaryConnectionString := "" - if iothubDps.Properties != nil && iothubDps.Properties.DeviceProvisioningHostName != nil { - hostname := iothubDps.Properties.DeviceProvisioningHostName + if iothubDps.Properties != nil && iothubDps.Properties.ServiceOperationsHostName != nil { + hostname := iothubDps.Properties.ServiceOperationsHostName if primary := accessPolicy.PrimaryKey; primary != nil { primaryConnectionString = getSAPConnectionString(*hostname, keyName, *primary) }