Hello Lior Shahar,
Thank you for posting your query here!
I understand you are getting "ResourceNotFound" error while attempting to execute the "Get Container ACL" operation with the Azure SDK for Java. There are a few possible reasons for this, please verify the below aspects:
· Verify and update the connection string. You can find the connection string in the Azure portal, under the "Access keys" section of the storage account. You can also regenerate the account key if it has been compromised or expired.
· Verify that the account has the necessary permissions to read container properties.
· If possible, try to change the public access level of the container to ‘Enable from all networks’ and check.
· Please ensure that you are using an updated version of the Azure SDK for Java.
Please check with the following code and let us know if it helps:
import com.azure.storage.blob.BlobContainerClient;
import com.azure.storage.blob.BlobServiceClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import com.azure.storage.blob.models.BlobContainerAccessPolicies;
import com.azure.storage.blob.models.BlobContainerProperties;
import com.azure.storage.blob.models.PublicAccessType;
public class AzureBlobExample {
public static void main(String[] args) {
String connectionString = "<your_connection_string>";
String containerName = "<your_container_name>";
// Build the BlobServiceClient
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(connectionString)
.buildClient();
// Get the BlobContainerClient
BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient(containerName);
// Check if the container exists
if (blobContainerClient.exists()) {
try {
// Get container properties
BlobContainerProperties containerProperties = blobContainerClient.getProperties();
System.out.println("Container properties retrieved successfully.");
// Get container access policies
BlobContainerAccessPolicies accessPolicies = blobContainerClient.getAccessPolicy();
PublicAccessType publicAccess = accessPolicies.getBlobAccessType();
System.out.println("Public access type: " + publicAccess);
accessPolicies.getIdentifiers().forEach(identifier -> {
System.out.println("Policy ID: " + identifier.getId());
});
} catch (Exception e) {
e.printStackTrace();
}
} else {
System.err.println("Error: Container not found.");
}
}
}
You may also enable logging to get detailed information about the operations being performed and the specific point of failure.
Do let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.