AssetsClient.CreateAsync Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Ajoute une nouvelle ressource à un partage existant.
public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> CreateAsync (Azure.WaitUntil waitUntil, string sentShareName, string assetName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateAsync : Azure.WaitUntil * string * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.CreateAsync : Azure.WaitUntil * string * string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function CreateAsync (waitUntil As WaitUntil, sentShareName As String, assetName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Operation(Of BinaryData))
Paramètres
- waitUntil
- WaitUntil
Completed si la méthode doit attendre pour retourner jusqu’à ce que l’opération de longue durée soit terminée sur le service ; Started si elle doit être retournée après le démarrage de l’opération. Pour plus d’informations sur les opérations de longue durée, consultez Exemples d’opérations de Long-Running Azure.Core.
- sentShareName
- String
Nom du partage envoyé.
- assetName
- String
Nom de la ressource.
- content
- RequestContent
Contenu à envoyer en tant que corps de la demande. Les détails du schéma du corps de la demande se trouvent dans la section Remarques ci-dessous.
- context
- RequestContext
Contexte de la demande, qui peut remplacer les comportements par défaut du pipeline client par appel.
Retours
du Operation<T> service qui contiendra un BinaryData objet une fois l’opération asynchrone sur le service terminée. Les détails du schéma du corps pour la valeur finale de l’opération se trouvent dans la section Remarques ci-dessous.
Exceptions
sentShareName
, assetName
ou content
a la valeur Null.
sentShareName
ou assetName
est une chaîne vide, et était censé être non vide.
Le service a retourné un code de status non réussi.
Exemples
Cet exemple montre comment appeler CreateAsync avec les paramètres requis et demander du contenu et analyser le résultat.
var credential = new DefaultAzureCredential();
var client = new AssetsClient("<https://my-service.azure.com>", credential);
var data = new {
kind = "AdlsGen2Account",
properties = new {
paths = new[] {
new {
containerName = "<StorageAccountPathContainerName>",
receiverPath = "<StorageAccountPathReceiverPath>",
senderPath = "<StorageAccountPathSenderPath>",
}
},
receiverAssetName = "<AdlsGen2AccountAssetPropertiesReceiverAssetName>",
storageAccountResourceId = "<AdlsGen2AccountAssetPropertiesStorageAccountResourceId>",
},
};
var operation = await client.CreateAsync(WaitUntil.Completed, "<sentShareName>", "<assetName>", RequestContent.Create(data));
BinaryData data = await operation.WaitForCompletionAsync();
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("kind").ToString());
Remarques
Créer une ressource sur un partage envoyé
Vous trouverez ci-dessous le schéma JSON pour les charges utiles de requête et de réponse.
Corps de la demande :
Cette méthode prend l’un des objets JSON ci-dessous en tant que charge utile. Sélectionnez un objet JSON pour afficher le schéma correspondant.
AdlsGen2AccountAsset
Schéma pourAdlsGen2AccountAsset
:{
kind: AdlsGen2Account, # Required. The types of asset.
id: string, # Optional. The resource id of the resource.
name: string, # Optional. Name of the resource.
type: string, # Optional. Type of the resource.
properties: {
location: string, # Optional. Location of the adls gen2 storage account.
paths: [
{
containerName: string, # Required. Gets or sets the container name.
receiverPath: string, # Optional. Gets or sets the path on the receiver side where the asset is to be mapped.
senderPath: string, # Optional. Gets or sets the path to file/folder within the container to be shared.
}
], # Required. A list of adls gen2 storage account paths to be shared.
provisioningState: "Unknown" | "Succeeded" | "Creating" | "Deleting" | "Moving" | "Failed" | "SoftDeleting" | "SoftDeleted" | "SourceMoved" | "SourceDeleted" | "TargetMoved" | "TargetDeleted", # Optional. Provisioning status of the resource
receiverAssetName: string, # Required. Name of the asset for the receiver.
storageAccountResourceId: string, # Required. Resource id of the adls gen2 storage account.
}, # Required. Adls gen 2 account asset properties
}
~+ 1 autres objets
BlobAccountAsset
Schéma pourBlobAccountAsset
:{
kind: BlobAccount, # Required. The types of asset.
id: string, # Optional. The resource id of the resource.
name: string, # Optional. Name of the resource.
type: string, # Optional. Type of the resource.
properties: {
location: string, # Optional. Location of the blob storage account.
paths: [
{
containerName: string, # Required. Gets or sets the container name.
receiverPath: string, # Optional. Gets or sets the path on the receiver side where the asset is to be mapped.
senderPath: string, # Optional. Gets or sets the path to file/folder within the container to be shared.
}
], # Required. A list of blob storage account paths to be shared.
provisioningState: "Unknown" | "Succeeded" | "Creating" | "Deleting" | "Moving" | "Failed" | "SoftDeleting" | "SoftDeleted" | "SourceMoved" | "SourceDeleted" | "TargetMoved" | "TargetDeleted", # Optional. Provisioning status of the resource
receiverAssetName: string, # Required. Name of the asset for the receiver.
storageAccountResourceId: string, # Required. Resource id of the blob storage account.
}, # Required. Blob storage account asset properties
}
Corps de réponse :
Cette méthode prend l’un des objets JSON ci-dessous en tant que charge utile. Sélectionnez un objet JSON pour afficher le schéma correspondant.
AdlsGen2AccountAsset
Schéma pourAdlsGen2AccountAsset
:{
kind: AdlsGen2Account, # Required. The types of asset.
id: string, # Optional. The resource id of the resource.
name: string, # Optional. Name of the resource.
type: string, # Optional. Type of the resource.
properties: {
location: string, # Optional. Location of the adls gen2 storage account.
paths: [
{
containerName: string, # Required. Gets or sets the container name.
receiverPath: string, # Optional. Gets or sets the path on the receiver side where the asset is to be mapped.
senderPath: string, # Optional. Gets or sets the path to file/folder within the container to be shared.
}
], # Required. A list of adls gen2 storage account paths to be shared.
provisioningState: "Unknown" | "Succeeded" | "Creating" | "Deleting" | "Moving" | "Failed" | "SoftDeleting" | "SoftDeleted" | "SourceMoved" | "SourceDeleted" | "TargetMoved" | "TargetDeleted", # Optional. Provisioning status of the resource
receiverAssetName: string, # Required. Name of the asset for the receiver.
storageAccountResourceId: string, # Required. Resource id of the adls gen2 storage account.
}, # Required. Adls gen 2 account asset properties
}
~+ 1 autres objets
BlobAccountAsset
Schéma pourBlobAccountAsset
:{
kind: BlobAccount, # Required. The types of asset.
id: string, # Optional. The resource id of the resource.
name: string, # Optional. Name of the resource.
type: string, # Optional. Type of the resource.
properties: {
location: string, # Optional. Location of the blob storage account.
paths: [
{
containerName: string, # Required. Gets or sets the container name.
receiverPath: string, # Optional. Gets or sets the path on the receiver side where the asset is to be mapped.
senderPath: string, # Optional. Gets or sets the path to file/folder within the container to be shared.
}
], # Required. A list of blob storage account paths to be shared.
provisioningState: "Unknown" | "Succeeded" | "Creating" | "Deleting" | "Moving" | "Failed" | "SoftDeleting" | "SoftDeleted" | "SourceMoved" | "SourceDeleted" | "TargetMoved" | "TargetDeleted", # Optional. Provisioning status of the resource
receiverAssetName: string, # Required. Name of the asset for the receiver.
storageAccountResourceId: string, # Required. Resource id of the blob storage account.
}, # Required. Blob storage account asset properties
}
S’applique à
Azure SDK for .NET