/// <inheritdoc/>
        public async Task <IResourceGroupResource> CreateAsync(string resourceGroup,
                                                               bool deleteOnDispose, ISubscriptionInfo subscription)
        {
            subscription = CompositeInfo.Create(subscription, _subscription);

            // Create resource group
            var client = await CreateClientAsync(subscription);

            if (string.IsNullOrEmpty(resourceGroup))
            {
                // Create group name
                while (true)
                {
                    resourceGroup = StringEx.CreateUnique(8, "rg");
                    var exists = await client.ResourceGroups.ContainAsync(
                        resourceGroup);

                    if (!exists)
                    {
                        break;
                    }
                }
            }
            else
            {
                var exists = await client.ResourceGroups.ContainAsync(
                    resourceGroup);

                if (exists)
                {
                    throw new ExternalDependencyException("resource group already exists");
                }
            }

            var region = await subscription.GetRegionAsync();

            _logger.Information("Creating simulation group {resourceGroup} in {region}...",
                                resourceGroup, region);
            var rg = await client.ResourceGroups.Define(resourceGroup)
                     .WithRegion(region)
                     .CreateAsync();

            _logger.Information("Created resource group {resourceGroup}.", rg.Name);
            return(new ResourceGroupResource(this, rg, deleteOnDispose, subscription, _logger));
        }
        /// <inheritdoc/>
        public async Task <IResourceGroupResource> GetAsync(string resourceGroup,
                                                            bool deleteOnDispose, ISubscriptionInfo subscription)
        {
            if (string.IsNullOrEmpty(resourceGroup))
            {
                throw new ArgumentNullException(nameof(resourceGroup));
            }
            subscription = CompositeInfo.Create(subscription, _subscription);
            var client = await CreateClientAsync(subscription);

            var rg = await client.ResourceGroups.GetByNameAsync(resourceGroup);

            if (rg == null)
            {
                return(null);
            }
            return(new ResourceGroupResource(this, rg, deleteOnDispose,
                                             subscription, _logger));
        }