Share via


IFileStagingArtifact Interface

Definition

Contains information about a file staging process. File staging is typically performed for a CloudTask (see FilesToStage).

public interface IFileStagingArtifact
type IFileStagingArtifact = interface
Public Interface IFileStagingArtifact
Derived

Remarks

IFileStagingArtifact allows an application to customize and to obtain information about the process of uploading files to the cloud, for example as part of a task-related operation such as JobOperations.AddTaskAsync or CloudJob.AddTaskAsync. Applications may use this information to, for example, find out about containers that were created in Azure Storage as part of the upload process.

When JobOperations.AddTaskAsync is called, the Batch client sends the tasks to the Batch service in collections. As each collection is processed, the Batch client performs file staging for that collection: it examines the tasks to see if any of them specify any FilesToStage, and if so creates a dictionary entry for each type of IFileStagingProvider in the FilesToStage collection. The key of the dictionary entry is the Type of the IFileStagingProvider and the value is an instance of the corresponding implementation of IFileStagingArtifact. For example, if FilesToStage includes one or more FileToStage objects (from the Microsoft.Azure.Batch.FileStaging library), then the dictionary contains an entry whose key is typeof(FileToStage) and whose value is an instance of SequentialFileStagingArtifact.

When the Add Task operation completes, or during the Add Task operation if the application is multi-threaded, you can examine the dictionary and convert each IFileStagingArtifact to the appropriate type to retrieve the type-specific information. For example, if your Add Task operation specified one or more FileToStage objects, you can locate the dictionary entry keyed by typeof(FileToStage), cast the value to SequentialFileStagingArtifact, and examine the SequentialFileStagingArtifact.BlobContainerCreated property to determine if the upload process created a blob container in Azure Storage and if so the name of that container. This example could be useful for cleaning up automatically created containers.

(Single-task Add Task operations work similarly, except that in a multi-task Add Task operation, there is a dictionary for each collection of tasks, and the dictionaries are collected in a ConcurrentBag<T>, whereas in a single-task Add Task operation there is only a single dictionary.)

In a single-task Add Task operation, you can also use the dictionary to customize the file staging process, by pre-populating it with appropriate entries. For example, suppose you wish to control the NamingFragment for a group of FileToStage objects. Then you could initialize the dictionary with { typeof(FileToStage), new SequentialFileStagingArtifact { NamingFragment = "myname" } } before passing it to AddTaskAsync. The FileToStage implementation of IFileStagingProvider would then use your SequentialFileStagingArtifact instead of creating its own. (This feature is not available in multi-task Add Task operations.)

You may also encounter IFileStagingArtifact if you are developing a custom IFileStagingProvider. In this case you will typically create a custom implementation of IFileStagingArtifact to report implementation-specific information about your file staging process.

Properties

NamingFragment

Gets or sets a name fragment that can be used when constructing default names.

Applies to