leo lee I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!
Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.
Error Message:
I used the ESP32S3 for azure iot connection and according to the code I have done the following:
DPS:
prvConnectToServerWithBackoffRetries --> OK
AzureIoTProvisioningClient_Init --> OK
AzureIoTProvisioningClient_Register --> OK
AzureIoTProvisioningClient_GetDeviceAndHub --> OK
IoT Hub:
prvConnectToServerWithBackoffRetries --> OK
AzureIoTHubClient_OptionsInit --> OK
AzureIoTHubClient_Init --> OK
But it fails in the call to AzureIoTHubClient_Connect with the previous log messages. AzureIoTResult_t value is 1.
We also encountered the same problem, and then we updated the certificate and this problem still occurred:
E (28665) MQTT: Connection refused: not authorized.
E (28665) MQTT: CONNACK recv failed with status = MQTTServerRefused.
E (28675) MQTT: MQTT connection failed with status = MQTTServerRefused.
E (28685) AZ IOT: Failed to establish MQTT connection: Server=XXX.azure-devices.net, MQTT error=0x00000006.
In the same question, I saw that deleting the Module ID would allow me to connect to azure iot, but I tried to leave the MODULE ID unconfigured or leave it empty.
Solution:
Before, I used the routine of azure-iot-middleware-freertos for reference to Microsoft's official instructions, but it corresponds to ESPRESSIF ESP32-Azure IoT Kit, but I used the chip of esp32s3. Therefore, I cannot connect to azure iot hub. I have successfully connected to azure iot hub after converting the routine.
If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.