public Task <YJsonResult <YResource> > CreateResourceGroupAsync(string name, [FromBody] YResourceGroupPayload payload) { return(YExecuteAsync(async() => { if (name is null) { throw new ArgumentNullException(nameof(name)); } var response = await this.client.ProcessRequestApiAsync <YResource>($"api/ResourceGroups/{name}", null, payload, HttpMethod.Put).ConfigureAwait(false); return response.Value; })); }
public async Task <YResource> CreateResourceGroupAsync(string name, [FromBody] YResourceGroupPayload payload) { payload.Location.EnsureLocation(); name.EnsureStringIsLetterOrDigit(); var check = await this.client.CheckResourceNameIsValidAsync(name, "Microsoft.Resources/subscriptions/resourcegroups"); if (check.Value.Status != "Allowed") { throw new Exception($"Name {name} is not allowed"); } var resourceRequest = new YResource { Location = payload.Location, Tags = payload.Tags }; var resourceResponse = await this.client.CreateOrUpdateAsync(name, ApiVersion, resourceRequest); return(resourceResponse.Value); }