0

In Azure storage we can set the immutability policy either to a container or to individual blobs of a container. I want to set immutability policy scoped to Azure containers using the V12 Java SDK of Azure. I came across the BlobContainerClient class present in the com.azure.storage.blob package of V12 SDK using which I can get a boolean that tells whether any immutability policy has been configured or not for a particular container in the following way:

blobContainerClient.getProperties().hasImmutabilityPolicy()

But I do not see any method that gives the ability to set the immutability lock duration scoped to containers.

Currently I am using the public final class Azure present in the legacy com.microsoft.azure.management java package to get and set the immutability lock duration of containers. But I am trying to move away from this legacy package and use the more recent V12 SDK. The reason for this is that the legacy package methods require lots of inputs like clientId, tenantId, subscriptionId, etc to set and set the container level immutability.

I have been successfully able to get and set immutability duration of individual blobs using the BlobClient class of V12 SDK without these inputs like this

blobClient.setImmutabilityPolicy(
        new BlobImmutabilityPolicy()
          .setPolicyMode(BlobImmutabilityPolicyMode.LOCKED)
          .setExpiryTime(
            newImmutabilityLockExpirationTime
          )
      )

But I am unable to do the same for containers. I need something like

blobContainerClient.setImmutabilityPolicy()

A lot of Googling and reading through documentation did not help me. Can anyone please help?

  • What is the error message you are receiving when you use -blobContainerClient.setImmutabilityPolicy() – Sourav Feb 03 '23 at 10:49

0 Answers0