/// <summary> /// Create a resource with a ResourceGroupOperations. /// </summary> /// <param name="name"> A string representing the name of the resource />. </param> /// <param name="model"> The model representing the object to create. />. </param> /// <param name="location"> A Location of where to to host the resource. />. </param> /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param> /// <typeparam name="TContainer"> The type of the class containing the container for the specific resource. </typeparam> /// <typeparam name="TOperations"> The type of the operations class for a specific resource. </typeparam> /// <typeparam name="TResource"> The type of the class containing properties for the underlying resource. </typeparam> /// <returns> A <see cref="Task"/> that on completion returns a response with the <see cref="ArmResponse{TOperations}"/> operation for this resource. </returns> public Task <ArmResponse <TOperations> > CreateResourceAsync <TContainer, TOperations, TResource>(string name, TResource model, LocationData location = default, CancellationToken cancellationToken = default) where TResource : TrackedResource where TOperations : ResourceOperationsBase <TOperations> where TContainer : ResourceContainerBase <TOperations, TResource> { var myResource = model as TrackedResource; if (myResource == null) { myResource = new GenericResourceData(Id); } if (location != null) { myResource = new GenericResourceData(Id, location); } TContainer container = Activator.CreateInstance(typeof(TContainer), ClientOptions, myResource) as TContainer; return(container.CreateOrUpdateAsync(name, model, cancellationToken)); }
/// <summary> /// Initializes a new instance of the <see cref="GenericResource"/> class. /// </summary> /// <param name="operations"> The operations object to copy the client parameters from. </param> /// <param name="resource"> The data model representing the generic azure resource. </param> /// <exception cref="ArgumentNullException"> If <see cref="AzureResourceManagerClientOptions"/> or <see cref="TokenCredential"/> is null. </exception> internal GenericResource(ResourceOperationsBase operations, GenericResourceData resource) : base(operations, resource.Id) { Data = resource; }