Exemplo n.º 1
0
        public IResourceGroup GetAzureResourceGroup(AzureAdOptions azureAdOptions,
                                                    string resourceGroupName)
        {
            IAzure azure = _azureSdkService.GetAzureSdk(azureAdOptions);

            IResourceGroup resourceGroup = null;

            if (azure.ResourceGroups.Contain(resourceGroupName))
            {
                resourceGroup = azure.ResourceGroups.GetByName(resourceGroupName);
            }

            return(resourceGroup);
        }
Exemplo n.º 2
0
        public void CreateResourceGroupTag(AzureAdOptions azureAdOptions, string resourceGroupName, string tagKey, string tagValue)
        {
            IAzure azure = _azureSdkService.GetAzureSdk(azureAdOptions);

            if (azure.ResourceGroups.Contain(resourceGroupName))
            {
                var resourceGroup = azure.ResourceGroups.GetByName(resourceGroupName);

                resourceGroup.Update()
                .WithTag(tagKey, tagValue)
                .Apply();
            }
            else
            {
                throw new ApplicationException($"ERROR: Create ResourceGroupTag: Unable to find resource group called '{resourceGroupName}'.");
            }
        }
Exemplo n.º 3
0
        public void CreateAzureResourceGroup(AzureAdOptions azureAdOptions,
                                             string resourceGroupName, string regionName, Dictionary <string, string> tags = null)
        {
            IAzure azure = _azureSdkService.GetAzureSdk(azureAdOptions);

            if (!azure.ResourceGroups.Contain(resourceGroupName))
            {
                var region = AzureRegionService.GetRegion(regionName);

                if (region == null)
                {
                    throw new ApplicationException($"{regionName}");
                }

                var resourceGroup = azure.ResourceGroups
                                    .Define(resourceGroupName)
                                    .WithRegion(region)
                                    .WithTags(tags)
                                    .Create();
            }
        }
Exemplo n.º 4
0
 public IAzure GetAzureSdk(AzureAdOptions azureAdOptions)
 {
     return(GetAzureSdk(azureAdOptions.ClientId, azureAdOptions.ClientSecret,
                        azureAdOptions.TenantId, azureAdOptions.SubscriptionId));
 }
Exemplo n.º 5
0
 public IAuthenticated GetAuthenticatedSdk(AzureAdOptions azureAdOptions)
 {
     return(GetAuthenticatedSdk(azureAdOptions.ClientId, azureAdOptions.ClientSecret,
                                azureAdOptions.TenantId, azureAdOptions.SubscriptionId));
 }