Hello @John Wong Yek Hon ,
welcome to this moderated Azure community forum.
Each Azure IoT Hub Device has its own credentials.
For a symmetric key, a primary and secundary key are provided.
You need to renew the keys yourself, for each device separately.
Here is a working C# example:
var rm = RegistryManager.CreateFromConnectionString("[connectionstring]");
var deviceId = "testDevice";
var device = await rm.GetDeviceAsync(deviceId);
var primaryKey = Guid.NewGuid();
byte[] primaryKeyBytes = Encoding.UTF8.GetBytes(primaryKey.ToString());
string base64PrimaryKey = Convert.ToBase64String(primaryKeyBytes);
device.Authentication.SymmetricKey.PrimaryKey = base64PrimaryKey;
device = await rm.UpdateDeviceAsync(device, true);
You need to generate the key based on a GUID and update the device via the RegistryManager.
This class is available in the Azure Devices server SDK.
<PackageReference Include="Microsoft.Azure.Devices" Version="1.39.1" />
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.