AssetsClient.CreateAsync Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Agrega un nuevo recurso a un recurso compartido existente.
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))
Parámetros
- waitUntil
- WaitUntil
Completed si el método debe esperar a que se devuelva hasta que se haya completado la operación de larga duración en el servicio; Started si debe devolverse después de iniciar la operación. Para más información sobre las operaciones de larga duración, consulte Ejemplos de operaciones de azure.Core Long-Running.
- sentShareName
- String
Nombre del recurso compartido enviado.
- assetName
- String
Nombre del recurso.
- content
- RequestContent
Contenido que se va a enviar como el cuerpo de la solicitud. Los detalles del esquema del cuerpo de la solicitud se encuentran en la sección Comentarios a continuación.
- context
- RequestContext
Contexto de solicitud, que puede invalidar los comportamientos predeterminados de la canalización de cliente por llamada.
Devoluciones
del Operation<T> servicio que contendrá un BinaryData objeto una vez completada la operación asincrónica en el servicio. Los detalles del esquema del cuerpo para el valor final de la operación se encuentran en la sección Comentarios a continuación.
Excepciones
sentShareName
, assetName
o content
es un valor null.
sentShareName
o assetName
es una cadena vacía y se espera que no esté vacía.
El servicio devolvió un código de estado no correcto.
Ejemplos
En este ejemplo se muestra cómo llamar a CreateAsync con los parámetros necesarios y solicitar contenido y analizar el resultado.
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());
Comentarios
Creación de un recurso en un recurso compartido enviado
A continuación se muestra el esquema JSON para las cargas de solicitud y respuesta.
Cuerpo de la solicitud:
Este método toma uno de los objetos JSON siguientes como una carga útil. Seleccione un objeto JSON para ver el esquema.
AdlsGen2AccountAsset
Esquema paraAdlsGen2AccountAsset
:{
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 objetos
BlobAccountAsset
Esquema paraBlobAccountAsset
:{
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
}
Cuerpo de la respuesta:
Este método toma uno de los objetos JSON siguientes como una carga útil. Seleccione un objeto JSON para ver el esquema.
AdlsGen2AccountAsset
Esquema paraAdlsGen2AccountAsset
:{
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 objetos
BlobAccountAsset
Esquema paraBlobAccountAsset
:{
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
}
Se aplica a
Azure SDK for .NET