public async Task <bool> Exists(String DisplayName)
        {
            var pwsh = shellRunner.CreateCommandBuilder();

            pwsh.SetUnrestrictedExecution();
            pwsh.AddCommand($"Import-Module Az.Resources");
            pwsh.AddResultCommand($"Get-AzADServicePrincipal -DisplayName {DisplayName} | ConvertTo-Json -Depth 10");

            var result = await shellRunner.RunProcessAsync(pwsh,
                                                           invalidExitCodeMessage : $"Error getting service principal '{DisplayName}'.");

            return(result.Type != Newtonsoft.Json.Linq.JTokenType.Null);
        }
Example #2
0
        public async Task <bool> IsNameAvailable(String Name)
        {
            var pwsh = shellRunner.CreateCommandBuilder();

            pwsh.SetUnrestrictedExecution();
            pwsh.AddCommand($"Import-Module Az.ContainerRegistry");
            pwsh.AddResultCommand($"Test-AzContainerRegistryNameAvailability -Name {Name} | ConvertTo-Json -Depth 10");

            dynamic result = await shellRunner.RunProcessAsync(pwsh,
                                                               invalidExitCodeMessage : $"Error testing Azure Container Registry name availability for '{Name}'.");

            return(result.NameAvailable);
        }
Example #3
0
        public async Task <String?> GetSecret(String keyVaultName, String name)
        {
            var pwsh = shellRunner.CreateCommandBuilder();

            pwsh.SetUnrestrictedExecution();
            pwsh.AddCommand($"Import-Module Az.KeyVault");
            pwsh.AddCommand($"$secret = Get-AzKeyVaultSecret -VaultName {keyVaultName} -Name {name}");
            pwsh.AddCommand($"$final = $null");
            pwsh.AddCommand($"if($secret -ne $null) {{ $final = ConvertFrom-SecureString -SecureString $secret.SecretValue -AsPlainText }}");
            pwsh.AddResultCommand($"$final | ConvertTo-Json -Depth 10");

            dynamic info = await shellRunner.RunProcessAsync(pwsh,
                                                             invalidExitCodeMessage : $"Error loading '{name}' from Key Vault '{keyVaultName}'.");

            return(info);
        }
Example #4
0
        public async Task <String> GetAppInsightsInstrumentationKey(String Name, String ResourceGroupName)
        {
            var pwsh = shellRunner.CreateCommandBuilder();

            pwsh.SetUnrestrictedExecution();
            pwsh.AddCommand($"Import-Module Az.ApplicationInsights");
            pwsh.AddResultCommand($"Get-AzApplicationInsights -Name {Name} -ResourceGroupName {ResourceGroupName} | ConvertTo-Json -Depth 10");

            dynamic result = await shellRunner.RunProcessAsync(pwsh,
                                                               invalidExitCodeMessage : $"Error getting App Insights instrumentation key for '{Name}' in Resource Group '{ResourceGroupName}'.");

            return(result.InstrumentationKey);
        }
        public async Task <String> GetPublicIp(String Name)
        {
            var pwsh = shellRunner.CreateCommandBuilder();

            pwsh.SetUnrestrictedExecution();
            pwsh.AddCommand($"Import-Module Az.Network");
            pwsh.AddResultCommand($"Get-AzPublicIpAddress -Name {Name} | ConvertTo-Json -Depth 10");

            dynamic result = await shellRunner.RunProcessAsync(pwsh,
                                                               invalidExitCodeMessage : $"Error getting Public Ip Address '{Name}'.");

            return(result.IpAddress);
        }