Include comments for public functions.
This commit is contained in:
Родитель
d5c7c240b8
Коммит
f48ef21ab4
|
@ -10,6 +10,7 @@ module Backup =
|
|||
/// Use a generated filepath.
|
||||
let GeneratedBackupPath = Option<FilePath>.None
|
||||
|
||||
/// List tables and then create backups of each one in parallel.
|
||||
let backupTables : BackupTables =
|
||||
fun listTables dumpTable backupPath ->
|
||||
async {
|
||||
|
@ -22,6 +23,7 @@ module Backup =
|
|||
return backupPath
|
||||
}
|
||||
|
||||
/// List all of the storage tables in the account.
|
||||
let listStorageTables (cloudTableClient:CloudTableClient) : ListTables =
|
||||
async {
|
||||
let rec getTables (continuationToken) (acc:CloudTable list) =
|
||||
|
@ -36,6 +38,7 @@ module Backup =
|
|||
return allTables |> List.map (fun t -> t.Name)
|
||||
}
|
||||
|
||||
/// Query for all the data in the table and write each record to a JSON file.
|
||||
let dumpTableToJsonFiles (cloudTableClient:CloudTableClient) : DumpTable =
|
||||
fun (tableName, filePath) ->
|
||||
async {
|
||||
|
|
|
@ -6,6 +6,7 @@ open Microsoft.Azure.Storage.DataMovement
|
|||
|
||||
module ContainerSync =
|
||||
|
||||
/// Synchronize a local archive directory with a storage account container directory.
|
||||
let syncToContainer (blobClient:CloudBlobClient) (reportProgress:Progress<TransferStatus> option) : SyncBackupToStorage =
|
||||
fun backupLocation ->
|
||||
async {
|
||||
|
@ -24,6 +25,7 @@ module ContainerSync =
|
|||
return Ok ()
|
||||
}
|
||||
|
||||
/// Synchronize a storage account container directory with a local directory for restoring an archive.
|
||||
let syncFromContainer (blobClient:CloudBlobClient) (reportProgress:Progress<TransferStatus> option) : SyncStorageToRestore =
|
||||
fun (restoreLocation:RestoreLocation) ->
|
||||
async {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
namespace AzureTableArchiver
|
||||
|
||||
/// Alias to clarify the intention of a string as a TableName clearer.
|
||||
type TableName = string
|
||||
|
||||
/// Lists the storage tables in a storage account.
|
||||
type ListTables = Async<TableName list>
|
||||
|
||||
/// Alias to clarify the intention of a string as a FilePath clearer.
|
||||
type FilePath = string
|
||||
|
||||
/// Dumps a storage table to a list of files.
|
||||
|
|
|
@ -17,6 +17,7 @@ module EntitySerialization =
|
|||
Int32Value : Nullable<Int32>
|
||||
Int64Value : Nullable<Int64> }
|
||||
with
|
||||
/// Default record with every field set to default values - null / Nullable()
|
||||
static member Default =
|
||||
{
|
||||
EdmType = EdmType.String
|
||||
|
@ -29,6 +30,7 @@ module EntitySerialization =
|
|||
Int32Value = Nullable ()
|
||||
Int64Value = Nullable ()
|
||||
}
|
||||
/// Create an EntityProperty from a PropertyValue record.
|
||||
static member AsEntityProperty (propertyValue:PropertyValue) : EntityProperty =
|
||||
match propertyValue.EdmType with
|
||||
| EdmType.String ->
|
||||
|
@ -48,6 +50,7 @@ module EntitySerialization =
|
|||
| EdmType.Int64 ->
|
||||
EntityProperty(propertyValue.Int64Value)
|
||||
| _ -> null
|
||||
/// Create a PropertyValue record from an EntityProperty.
|
||||
static member OfEntityProperty (entityProperty:EntityProperty) : PropertyValue =
|
||||
match entityProperty.PropertyType with
|
||||
| EdmType.String ->
|
||||
|
@ -68,13 +71,16 @@ module EntitySerialization =
|
|||
{ PropertyValue.Default with EdmType = entityProperty.PropertyType; Int64Value = entityProperty.Int64Value }
|
||||
| _ -> PropertyValue.Default
|
||||
|
||||
/// Extension methods on DynamicTableEntity for converting to and from JSON
|
||||
type DynamicTableEntity with
|
||||
/// Converts this to a dictionary of PropertyValue records and serializes it to JSON.
|
||||
member this.ToJson () =
|
||||
let props =
|
||||
this.Properties
|
||||
|> Seq.map (fun kvp -> kvp.Key, (PropertyValue.OfEntityProperty kvp.Value))
|
||||
|> dict
|
||||
System.Text.Json.JsonSerializer.Serialize (props, System.Text.Json.JsonSerializerOptions (IgnoreNullValues=true))
|
||||
/// Parses JSON into a dictionary and PropertyValue records and converts each to EntityProperties on this entity.
|
||||
member this.LoadJson (json:string) =
|
||||
let (dictionary:System.Collections.Generic.Dictionary<string, PropertyValue>) = System.Text.Json.JsonSerializer.Deserialize json
|
||||
for kvp in dictionary do
|
||||
|
|
|
@ -5,12 +5,14 @@ open EntitySerialization
|
|||
|
||||
module Restore =
|
||||
|
||||
/// Reads a JSON file and deserializes it into a DynamicTableEntity.
|
||||
let entityFromJsonFile (partition:string) (rowKey:string) (filePath:string) : Async<DynamicTableEntity> =
|
||||
async {
|
||||
let! json = System.IO.File.ReadAllTextAsync filePath |> Async.AwaitTask
|
||||
return DynamicTableEntity(partition,rowKey).LoadJson json
|
||||
}
|
||||
|
||||
/// Reads files in each table partition directory in parallel and inserts or replaces the record in each table.
|
||||
let restoreTables (cloudTableClient:CloudTableClient) : RestoreTables =
|
||||
fun (filePath:FilePath) ->
|
||||
async {
|
||||
|
|
Загрузка…
Ссылка в новой задаче