BasicARMWebAPI.Controllers.ResourcesController.Put C# (CSharp) Method

Put() private method

private Put ( [ id, [ body, [ apiVersion = null ) : Task
id [
body [
apiVersion [
return Task
        public async Task<JsonExtendedResource> Put(
            [Metadata("Resource Id", "The Id of the resource")]string id,
            [Metadata("Properties", "Each resource has a different set of properties, you must provide the specific set that this resource requires")][FromBody]JsonBaseResource body,
            [Metadata("API version", "The version of the API you would like to call to get the resource properties.", VisibilityType.Advanced)]string apiVersion = null)
        {
            if (body == null)
            {
                throw new InvalidOperationException("You need to provide a vaild resource payload");
            }

            if (body.Location == null)
            {
                throw new InvalidOperationException("You need to provide a location for the resource");
            }

            var client = await ResourceUtilities.GetClient().ConfigureAwait(continueOnCapturedContext: false);

            apiVersion = await ResourceUtilities.GetLatestAPIVersion(client, id, apiVersion).ConfigureAwait(continueOnCapturedContext: false);

            var result = await client.Resources.CreateOrUpdateAsync(ResourceUtilities.GetResourceGroupFromId(id), ResourceUtilities.GetIdentityFromId(id, apiVersion), body.GetGenericResource(), CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);

            return new JsonExtendedResource(result.Resource);
        }