![]() | Azure |
public Task Put( Object? appKey, Object itemKey, Object? value )
The object value to put in the setting. The value may be null.
The object providing the setting's non-null value must be of a Type that is capable of being two-way serialized as a culture invariant string. Most .NET primitive structs and classes (int, long, Guid, etc) have type converters implicitly assigned to them to allow suitable serialization. The byte[] and string[] types do not have suitable default converters, but they are treated as special cases and converted correctly. Custom types will require a custom type converter to allow serialization. See the CustomClass in the test project for an example of a custom converter.
An alternative to creating a custom type converter is to encode a problematic object to a string of XML or JSON using the appropriate .NET utility classes and put the encoded string into the setting.
Azure Table documentation states that the size limit of a property value is 64K. It's unclear in what format the string value is stored, but if it's encoded as 2-byte Unicode then the limit for the serialized string value would be about 32K. Since application settings are typically small values, the limit is not epxected to be a problem in practical usage scenarios.
Exception | Condition |
---|---|
NotSupportedException | The value's Type is not capable of two-way serialization as a culture invariant string. Values can only be round-tripped as a setting if their Type is assigned a TypeConverter capable of converting the value to and from a string representation. Most .NET primitive structs and classes have implicit suitable converters, but user-defined classes will need a custom converter. |
ArgumentException | Thrown in the following conditions for a non-null value parameter: 1. The value is a string array with elements containing all of the reserved characters that can be used as delimiters in the serialized string. The value cannot be unambiguously serialized. 2. The value is a string array with an element equal to the special indicator string "__null__". The value cannot be unambiguously serialized. |