I tried to in my environment and got the below results:
You can follow this github link to achieve your requirement by adding service principal to Azure Blob Container by using the below code.
Code:
@GetMapping("/call")
public void assignBlob() throws IOException {
TokenCredential credential = new ClientSecretCredentialBuilder().clientId("client_id").clientSecret("client_secret").tenantId("tenant_id").build();
String connectionString = "DefaultEndpointsProtocol=https;AccountName=<storage_account_name>;AccountKey=<storage_account_key>;EndpointSuffix=core.windows.net";
BlobContainerClient containerClient = new BlobContainerClientBuilder().credential(credential).connectionString(connectionString).containerName("<conatiner_name>").buildClient();
BlobSignedIdentifier identifier = new BlobSignedIdentifier().setId("<your_another_service_principal_id>").setAccessPolicy(new BlobAccessPolicy().setStartsOn(OffsetDateTime.now()).setExpiresOn(OffsetDateTime.now().plusDays(7)).setPermissions("rw"));
// Set the access policy for the container
containerClient.setAccessPolicy(null, Collections.singletonList(identifier));
}
I have used the below-highlighted service principal id to provide access to my container.
Portal:

As it is shown below, I can add a service principal to the Azure Blob container.
Portal:
