コード例 #1
0
        public async Task Aquire(IAzureOptionsCommon options, IInputService _input)
        {
            var defaultEnvironment = (await Environment.GetValue()) ?? AzureEnvironments.AzureCloud;
            var environments       = new List <Choice <Func <Task> > >(
                AzureEnvironments.ResourceManagerUrls
                .OrderBy(kvp => kvp.Key)
                .Select(kvp =>
                        Choice.Create <Func <Task> >(() =>
            {
                options.AzureEnvironment = kvp.Key;
                return(Task.CompletedTask);
            },
                                                     description: kvp.Key,
                                                     @default: kvp.Key == defaultEnvironment)))
            {
                Choice.Create <Func <Task> >(async() => await InputUrl(_input, options), "Use a custom resource manager url")
            };
            var chosen = await _input.ChooseFromMenu("Which Azure environment are you using?", environments);

            await chosen.Invoke();

            options.UseMsi =
                await UseMsi.GetValue() == true ||
                await _input.PromptYesNo("Do you want to use a managed service identity?", false);

            if (!options.UseMsi)
            {
                // These options are only necessary for client id/secret authentication.
                options.TenantId = await TenantId.Interactive(_input, "Directory/tenant id").GetValue();

                options.ClientId = await ClientId.Interactive(_input, "Application client id").GetValue();

                options.Secret = await ClientSecret.Interactive(_input, "Application client secret").GetValue();
            }
        }
コード例 #2
0
        public async Task Default(IAzureOptionsCommon options)
        {
            options.UseMsi = await UseMsi.GetValue() == true;

            options.AzureEnvironment = await Environment.GetValue();

            if (!options.UseMsi)
            {
                // These options are only necessary for client id/secret authentication.
                options.TenantId = await TenantId.GetValue();

                options.ClientId = await ClientId.GetValue();

                options.Secret = await ClientSecret.GetValue();
            }
        }