locked
Setting immutability policy for Azure Blob storage by .net client RRS feed

  • Question

  • How do I set the immutability policy for a Azure blob container by .net client? I only found the getter container.Properties.HasImmutabilityPolicy, but no way to set the policy.

    Thanks in advance.

    Friday, November 2, 2018 7:08 AM

All replies

  • Hi,

    You should be able to set the immutability policy for Blob Storage in .NET by using the ImmutabilityPolicy() class.

    The following reference guide shows how you can implement this class in order to set the policy: https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.storage.models.immutabilitypolicy.-ctor?view=azure-dotnet#Microsoft_Azure_Management_Storage_Models_ImmutabilityPolicy__ctor

    If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click Here

    Monday, November 5, 2018 1:29 PM
  • Hi, 

     thank you for your answer. Do you also know a possibility to set the ImmutabilityPolicy in .net core?

    Tuesday, November 6, 2018 7:12 AM
  • The ImmutabilityPolicy() class should work for .NET Core as it's part of the Microsoft.Azure.Management.Storage.Models namespace package.

    If you haven't already done so, you can install this package using the following command from a command prompt window in your project's directory: dotnet add package Microsoft.Azure.Management.Storage.Models

    For your reference, the following guide shows how you can install packages for .NET Core using the dotnet add package command: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package

    I hope this helps.

    If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click Here

    Tuesday, November 6, 2018 8:09 AM
  • The problem is that the package Microsoft.Azure.Management.Storage is not compatible with .net core

    "Package war restored using .net framework instead of the target framework .netCoreApp, v2.1".

     And the class ImmutabilityPolicy() is not part of the package Microsoft.Azure.Management.Storage.Fluent.

    Tuesday, November 6, 2018 8:31 AM
  • Hi,

    Sorry for the delayed response while checking this for you.

    Unfortunately, not all of the .NET Core features are supported or available for Azure Storage as of yet.  This includes the ImmutabilityPolicy() that you need to set the policy. The only way this can be done is by using the standard .NET Framework, I'm afraid.

    In this case, I would recommend posting this as a feature request on our feedback page: https://feedback.azure.com/forums/217298-storage

    If this answer was helpful, click “Mark as Answer” or Up-Vote. To provide additional feedback on your forum experience, click Here

    • Proposed as answer by robrien-MSFT Thursday, November 8, 2018 10:02 AM
    Thursday, November 8, 2018 10:02 AM