コード例 #1
0
        public void AddAndAssignCertificate()
        {
            var helper    = new AuthenticationHelper(clientId1, returnUri);
            var ar        = helper.SimpleLogin("*****@*****.**", "Pass@word1");
            var azmHelper = new AzureManagementHelper(ar);
            var bytes     = File.ReadAllBytes(@"E:\gitrepos\JetDotCom\src\AzureResourceManagerDemo\wildcard.cicoriadevnet.pfx");
            var b64       = Convert.ToBase64String(bytes);

            azmHelper.AddCertificate(
                mySubscription,
                "Default-Web-EastUS",
                "East US",
                "Wildcard1",
                "pass@word1",
                b64);


            azmHelper.AssignCertificate(
                mySubscription,
                "Default-Web-EastUS",
                "East US",
                "scicoriacustom",
                "azw.cicoriadev.net",
                "DEA5DED6142EDECCDF952F4D431ED772F01D22D1");
        }
コード例 #2
0
        async Task <bool> ExecuteLoadStorageAccountsAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }
            try
            {
                IsBusy = true;
                NoStorageAccountsFound = false;
                var realm = App.GetRealm();
                if (force)
                {
                    var subs = realm.All <Subscription>().AsRealmCollection();
                    foreach (var sub in subs.Where(sub => sub.IsSubOn == false))
                    {
                        realm.Write(() =>
                        {
                            var sas = realm.All <StorageAccountExt>().Where(sa => sa.SubscriptionName == sub.Name);
                            realm.RemoveRange(sas);
                        });
                    }
                    foreach (var sub in subs.Where(sub => sub.IsSubOn))
                    {
                        await AzureManagementHelper.GetStorageAccountsForSubscription(
                            sub.Id, signOnClient.GetTokenForTenant(sub.TenantId), sub.Name, sub.TenantId);
                    }
                }


                var storageAccounts = realm.All <StorageAccountExt>();
                storageAccounts.SubscribeForNotifications((sender, changes, error) =>
                {
                    Console.WriteLine("Change to StorageAccount");
                });

                StorageAccounts.ReplaceRange(storageAccounts.OrderBy(sa => sa.Name));
                StorageAccountsGrouped.ReplaceRange(StorageAccounts.FilterBySubscription());

                if (StorageAccounts.Count == 0)
                {
                    NoStorageAccountsFoundMessage = "No Storage Accounts Found";
                    NoStorageAccountsFound        = true;
                }
                else
                {
                    NoStorageAccountsFound = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Report(ex, "Method", "ExecuteLoadStorageAccountsAsync");
                MessagingService.Current.SendMessage(MessageKeys.Error, ex);
            }
            finally
            {
                IsBusy = false;
            }
            return(true);
        }
コード例 #3
0
        async Task ExecuteLoginAsync()
        {
            try
            {
                IsBusy = true;
                var result = await signOnClient.Authenticate();

                Settings.Current.Email     = result.UserInfo.DisplayableId;
                Settings.Current.FirstName = result.UserInfo.GivenName;
                Settings.Current.LastName  = result.UserInfo.FamilyName;
                Message = "Sign in successful, fetching Subscriptions";
                var tenants = await Services.AzureSubscriptionInfoService.GetTenants(result.AccessToken);

                foreach (var tenant in tenants.TenantCollection)
                {
                    var subResult = await signOnClient.AuthenticateSilently(tenant.TenantId, result.UserInfo.UniqueId);

                    var subs = await Services.AzureSubscriptionInfoService.GetSubscriptionsForTenant(tenant.TenantId, subResult.AccessToken);

                    foreach (var sub in subs)
                    {
                        sub.tenantId = tenant.TenantId;
                    }
                    App.current.Subscriptions.AddRange(subs);
                }

                Message = "Subscriptions obtained, fetching Storage Accounts";
                foreach (var sub in App.current.Subscriptions)
                {
                    await AzureManagementHelper.GetStorageAccountsForSubscription(sub.SubscriptionId, sub.Token, sub.DisplayName, sub.tenantId);
                }
                //Send them to the navigation page
                var nav = Application.Current?.MainPage?.Navigation;
                if (nav == null)
                {
                    return;
                }
                Settings.FirstRun = false;
                Settings.Current.ForceUserLogin = false;
                await Navigation.PopModalAsync();

                MessagingService.Current.SendMessage(MessageKeys.NavigateToStorageAccounts);
            }
            catch (Exception ex)
            {
                Logger.Track(ASELoggerKeys.LoginFailure, "Reason", ex?.Message ?? string.Empty);
                MessagingService.Current.SendMessage <MessagingServiceAlert>(MessageKeys.Message, new MessagingServiceAlert
                {
                    Title   = "Unable to Sign in",
                    Message = "There was an issue signing in.",
                    Cancel  = "OK"
                });
                IsBusy = false;
            }
            finally
            {
                //IsBusy = false;
            }
        }
コード例 #4
0
        public void HasCertificates()
        {
            var azmHelper = new AzureManagementHelper(_authResultResourceManager);

            var certificates = azmHelper.Certificates(mySubscription);

            Assert.IsNotNull(certificates, "certificates is null");
            //Assert.IsTrue(providers.Count > 0, "no providers");
        }
コード例 #5
0
        public void HasSubscriptions()
        {
            var azmHelper = new AzureManagementHelper(_authResultSubscription);

            var rv = azmHelper.Subscriptions();

            Assert.IsNotNull(rv, "no subscriptions");
            Assert.IsTrue(rv.Count > 1, "Count zero");

            foreach (var item in rv)
            {
                Console.WriteLine("SubID: {0}  - Name: {1}", item.SubscriptionId, item.SubscriptionName);
            }
        }
コード例 #6
0
        public void AddCert()
        {
            var azmHelper = new AzureManagementHelper(_authResultResourceManager);

            var bytes = File.ReadAllBytes(@"E:\gitrepos\JetDotCom\src\AzureResourceManagerDemo\wildcard.cicoriadevnet.pfx");

            var b64 = Convert.ToBase64String(bytes);


            azmHelper.AddCertificate(
                mySubscription,
                "Default-Web-EastUS",
                "East US",
                "Wildcard1",
                "pass@word1",
                b64);
        }