[BUG] Can not set PrefixMatch on ManagementPolicyFilter
See original GitHub issueDescribe the bug Can not set PrefixMatch on ManagementPolicyFilter
Expected behavior Able to set PrefixMatch on ManagementPolicyFilter, either via construction or public property
Actual behavior (include Exception or Stack Trace) What is the actual behavior? Not able to set PrefixMatch on ManagementPolicyFilter, either via construction or public property. Please refer to following source code
public class ManagementPolicyFilter : IUtf8JsonSerializable
{
public ManagementPolicyFilter(IEnumerable<string> blobTypes);
public IList<string> PrefixMatch { get; }
}
To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)
Use following code to create ManagementPolicyRule instance, failed can not set PrefixMatch
var rules = new List<ManagementPolicyRule>();
var rule1 = new ManagementPolicyRule("DeleteLongerThan24Hours", RuleType.Lifecycle,
new ManagementPolicyDefinition(new ManagementPolicyAction {BaseBlob = new ManagementPolicyBaseBlob(){ Delete =new DateAfterModification(1)},})
{
Filters = new ManagementPolicyFilter(new List<string> { "blockBlob" })
{
PrefixMatch = new List<string> { "upload" }
}
});
rules.Add(rule1);
Environment:
- Name and version of the Library package used: [e.g. Azure.Storage.Blobs 12.2.0] azure.resourcemanager.storage 1.0.0-preview.2
- Hosting platform or OS and .NET runtime version (
dotnet --info
output for .NET Core projects): [e.g. Azure AppService or Windows 10 .NET Framework 4.8] Windows 10, DotNet Core - IDE and version : [e.g. Visual Studio 16.3] VS version does not matter
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Creating Azure Lifecycle Management rules from C# - ...
Is there a way to create Lifecycle Management rules for an Azure Storage Account directly from C#?. I know how to do it...
Read more >armstorage
GetProperties - Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account ...
Read more >Azure blob Storage Life Cycle Management not working ...
Based on the provided lifecycle rule configuration, it appears that the rule is set up correctly. However, there are a few factors to...
Read more >Azure storage deletion policy does not work
All blobs to be deleted in the container. I do not have any extra folders in that container. So with prefixMatch = queryresults...
Read more >Optimize costs by automatically managing the data lifecycle
Use Azure Storage lifecycle management policies to create automated rules for moving data between hot, cool, cold, and archive tiers.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @blrchen please try this:
Please note since the property
PrefixMatch
is unassignable, you cannot construct a new list and assign to that property. The SDK will initialize this property with a built-in List type, and the fact of no-setter could ensure you cannot change the list to another instance. The usage above is a C# grammar sugar of the collection initialization, check out more information here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#object-initializers-with-collection-read-only-property-initializationThis works, thanks man.