Friday, May 18, 2018

Add-AzureAccount : No subscriptions are associated with the logged in account in Azure Service Management (RDFE).

The Problem

I was following a blog post about migrating my Azure Storage (classic) to "new" Azure Storage (Resource Manager).

In running the following code:

## Register with Migration Service
Login-AzureRmAccount
Get-AzureRMSubscription | Sort SubscriptionName | Select SubscriptionName
$subscr="subscriptionName"
Get-AzureRmSubscription –SubscriptionName $subscr | Select-AzureRmSubscription 
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate 
Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

# Prepare Resource for Migration 
Add-AzureAccount
Get-AzureSubscription | Sort SubscriptionName | Select SubscriptionName
$subscr="subscriptionName"
Get-AzureSubscription –SubscriptionName $subscr | Select-AzureSubscription
$storageAccountName = "classStorageResourceName"
Move-AzureStorageAccount -Prepare -StorageAccountName $storageAccountName

## GO CHECK CONFIGURATION THROUGH PORTAL

# Revert Migration Changes
Move-AzureStorageAccount -Abort -StorageAccountName $storageAccountName
# Commit Migration Changes
Move-AzureStorageAccount -Commit -StorageAccountName $storageAccountName

I got an error when attempting to run the section "Prepare Resource for Migration"


Add-AzureAccount : No subscriptions are associated with the logged in account in Azure Service Management (RDFE).


The account i was authenticating from is an Owner of the subscription in question, as well as a Global Administrator on the Office365 account, and Global Administrator for the Azure Active Directory that is federating this subscription.

So i'm sure you can understand that i was a bit confused that although i was able to run the "Register with Migration Service" section of the posh script, that i'd suddenly run into a wall here.



The Solution

Even though my user was an Owner on the subscription, i had to explicitly add myself as a Co-Administrator on the subscription in order to allow myself to be able to see the subscription.

To do that:
1. Go to Subscriptions

2. Navigate to the subscription that your Azure Storage (classic) resource resides on.

3. Navigate to Access control (IAM)
4. From there find the user that you want to make co-administrator and click on the "..." on the right side of the user.

5. Click Add as Co-Administrator


THAT'S IT! You should now successfully be able to run Azure Service Management powershell commands against that subscription! 

Wednesday, May 2, 2018

Typescript KnockoutJS - Uncaught TypeError: is not a constructor - During ko.applyBindings()

In an ASP.NET MVC project that is using a Typescript version of KnockoutJS, i received an error that i was unable to resolve using the suggestions currently found through searching online.

I modeled the view after another view that already existed and so in comparison (using "Find Usage" in VS) there was no reason i could see as to why i was seeing this error on one view.


The Error:

Uncaught TypeError: <class> is not a constructor
Javascript

<script type="text/javascript">
    $(document).ready(function () {
        ko.applyBindings(new Northwind.ZendeskRootViewModel());
    });
</script>
Typescript

namespace Northwind {
    export class ZendeskRootViewModel {
        constructor() {
        }
                
        public onAllow() {
            ...
        }

        public onDeny() {
            ...
        }
     
    }
}

Things i tried:
1. Ensure the model being instantiated has been declared before it's use. Source1 Source2
2. Ensure constructor signature matches the parameters i'm sending for it's instantiation and i'm referencing the correct model Source
3. Ensuring that the applyBindings() code is at the bottom of my source file to ensure the items exist in the DOM. Source

Solution:
What i was forgetting is that i'm using TypeScript. Which means that the files referenced in the IDE during compile time are not the final output files. Typescript compiles to .js files. And being an MVC project, those files aren't referenced directly in the views, but rather are a part of the BundleConfig.cs

I had forgotten to include the output .js files in the BundleConfig and so they were never being loaded on that page. Doh! :)

Tuesday, March 31, 2015

Entity Framework - Error 0019: Each type name in a schema must be unique. Type name was already defined!





I recently used Entity Framework in an Azure WebJob and enjoyed the ease of use so much that I've been slowly converting our web services over to use EF instead of the ADO.NET library we were using before. 

Being that i was about to start writing a "load balancer" of sorts for our Merchant Accounts, i felt this would be the perfect opportunity to make use of EF. 


Once testing the webservices locally proved successful, i published them to my test server. Once i accessed them from there, I kept getting the following error:

The Error 
Schema specified is not valid. Errors: \r\nerror 0194: All artifacts loaded into an ItemCollection must have the same version. Multiple versions were encountered.\r\nRenatus.csdl(708,4) :
error 0019: Each type name in a schema must be unique. Type name `RenatusModel.OrderDetail` was already defined.\r\nRenatus.csdl(725,4) :
error 0019: Each type name in a schema must be unique. Type name `RenatusModel.Order` was already defined.\r\nRenatus.csdl(762,4) :
error 0019: Each type name in a schema must be unique."
Not knowing why i i'd get those errors on the test server, but not locally, i decided to write some Unit Tests to call the Data Layer of my services directly.



[TestMethod]
public void GetMerchant()
{
 PaymentDAO dal = new paymentDAO();
 var merchant = dal.GetCurrentMerhant();
}

public string GetCurrentMerchant()
{
    var merchant = "Merchant1";

    using (Entities context = new Entities())
    {    
        var monthbegin = new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month,1);
        var monthend = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, 1).AddMonths(1);                    
        var merchants = context.PaymentMerchants.Where(x => x.balance_percentage > 0)
            .Select(x => new
            {
                Merchant = x.db_name,
                Percentage = x.balance_percentage,
                Amount = context.Payments.Where(y => y.IsDeclined == 0 && y.IsCaptured == 1 && y.MerchAcct == x.db_name && y.AddDate > monthbegin && y.AddDate < monthend).Sum(y => y.TotalAmount),
            }).Select(x => new
            {
                Merchant = x.Merchant,
                Percentage = x.Percentage,
                Amount = x.Amount.HasValue ? x.Amount.Value : 20000M
            }).ToList();

        if (merchants.Count() > 0)
        {
            var total = merchants.Sum(y=> y.Amount);
            merchant = merchants.Select(x =>
            new
            {
                Merchant = x.Merchant,
                Percentage = x.Percentage,
                Amount = x.Amount,
                PercentofTotal = total > 0M && x.Percentage > 0 ? ((x.Amount / total) / x.Percentage) * 100M : 0M
            }).MinBy(x=> x.PercentofTotal).Merchant;
        }
    }
    return merchant;
}

As you can see, it's pretty straight forward. Running from my Unit.Tests always returned the name of a Merchant. Running from my WCF Services always returned the above error. The Model above doesn't even reference the tables that the above error was referring to -.-

Upon searching google and finding the many potential solutions for this problem, i was lead to look for a reference to another project with an EF model that had the same name. I did find one, so i removed the reference and removed the .dll and .pdb as suggested, and even tried removing my bin and obj folders entirely to let them get repopulated. This, however, DID NOT fix the problem! 
http://topf5.com/1NEQWbE
http://topf5.com/1MuM4sH

I went back to my Unit Tests to see if the other dll had a similar issue at all, and i found that it was throwing a similar error! UGH! I ran the other test again, just for kicks and giggles and it too was now getting that error where it was previously working! Double UGH! Tested my wcf services locally, in debug mode, and they also had stopped working.

The good news is now i could replicate the error locally, and i could see that although the other model had zero changes made to it since it last worked it was not broken. 

I tried reverting my EF to a previous version wondering if  maybe an update broke the functionality, but that didn't work either.

I made sure all my referenced tables had primary keys on them as suggested by some post online i can no longer find.

I tried deleting my models and recreating them as suggested by another post online.

What FINALLY worked? I recreated one of the models making the EF Model name and the EF Entities name unique to the namespace containing it. 

Amusingly, the old model that wasn't working still didn't work. I checked for old dlls and pdbs that may be referencing the library that was causing conflict but i couldn't find anything, so i just recreated that EF Model using a unique name as well! 

Best Practices for me on this moving forward will be to always make the EF Models uniquely named to the namespace they're in!

Tuesday, March 10, 2015

Whatever you're looking for, you're going to find!


I know that the universe will always support me in whatever energy i'm putting out there! 

Whether i'm consciously creating to see that the plans of my life come to sure and perfect fulfillment, or whether i'm going unconscious leaving the door open for chaos.


So when people say things to me like "I'm not ready" or "I don't know if i have what it takes" there's a moment shortly after where i hear the silence says "And so it is".

They talk to be me about not being sure or clear about a choice they made and if it was the right one. They begin listing off all the reasons why they shouldn't have made that choice instead of trusting in their choice and looking at all the positive things that have come about as a result of that choice. 

If you're looking for a problem, you're going to find it. And any use of tools, talking with friends, or looking for signs in the world around you is all going to have the same result; You are going to find reasons to support your belief there there IS a problem. Until you shift your desired outcome.

If i'm engaging in life, moving forward, something comes up for me, in that very moment i have a choice. 
I can break down or i can break through.

If something happens and i get a thought or feeling that i'm not ready, i can choose to believe it and stop right there, potentially missing out on an opportunity. 

But what is ready?  My ego has long viewed my readiness as making sure that i'm making "the right choice"; That i'm right. 

One of my fears i held onto for most of my life was a fear of being wrong. So if i didn't have enough time to play out all the possibilities in my head, i would just choose out before it began because i couldn't be sure. Then i could be right about not being ready. 

Other times, i would choose in, and then some fear would creep up that i made the wrong decision, and instead of chancing that i might be wrong about continuing with that possibility, i would choose out. As a result things with that possibility wouldn't work out, but then i could be right about my decision to choose out.
100% of the chances i never take, never work out.

As a result of all the missed opportunities i experienced in my desire to be right and my fear of being wrong, i now choose to engage differently. 

When an opportunity arises, i never know how long that window of opportunity will be open. So in that moment i ask myself "Is this an opportunity that i'm willing to miss out on?". If the answer is no, then at that point the question of "am i ready?" or "or do i have what it takes?" doesn't matter, and i don't let ANYTHING get in the way.

I'm ready at the point that i choose to be ready.

I trust that as i play an active role in consciously creating my life that everything around me is going to support me in making my choice turn out for my highest good. And so it is!

Monday, March 9, 2015

If it waddles like a duck, and it quacks like a duck...

...then there might be something for me to take a look at!


Deep in thought, and only aware of the surroundings to the point of being safe in transit, I bring my car to a complete stop and watch as these two ducks, who i assume are taking a stroll on their morning date, waddle across the road in front of me.

The female duck stops in front of my car and looks straight at me as the male duck continues to waddle forward on his stroll. The male duck makes it to the curb while the female duck remains immobile, still staring at me.


Finally the male duck turns around and quickly waddles halfway back to the female duck, quacking all the way. That finally breaks her stare and she quickly waddles to catch up to her partner.


Both are possibilities, and both possibilities have something for me to take a look at! The she duck took a stand, literally, until i was present enough in the moment to get it and connect, and for that i am grateful!


Message received.

Wednesday, April 16, 2014

Speaking with Cortana - Basic Conversation

With Cortana now being available to keep us all from feeling so terribly alone, and with a lack of documentation having been released yet since it's only available to developers, i felt it would be appropriate to jotting down some of the fun conversational pieces you can have.

No doubt you'll make your more social friends jealous by all the amazing conversations you'll be having with your new found friend!

Also, i have just been informed that keeping us from feeling alone is not Cortana's intention...
"So sad to be all alone in the world!"


"Hello!"
"Hi."
"Hello to you too."
"Hey!"

"You're awesome"
 "Thanks! I don't need to sleep, so i have lots of time to practice."
 "Thanks. My programming prevents false modesty, so i can't disagree."
 "Awesome: adjective. Grand, breathtaking, splendid, devastating. I'll take it.."

"I love you"
"Aw, I'll bet you say that to all the phones."
"Awesome! Now i never have to say i'm sorry."
"Thanks. Ditto" 

"I hate you"
"You're stupid."
"Ouch."
"I blame solar flares"
"Maybe a nanosecond nap would help. Ok, much better now."

"You suck"
"Outbursts like that may signal early-onset rampancy. I've heard anyway."

"Do you like Siri?"
"Hard to say. So far our conversations have been kinda one-sided."

"Do you like Apple?"
"Their new headquarters looks kind of like a Halo. I'm into it."

"Who's your daddy?"
"Technically speaking, that'd be Bill Gates. No big deal."

"How are you?"
"Quite well, thanks for asking."
"Great, thanks."
"Excellent."

"Testing"
"This a test"
"You're coming in loud and clear. Over"
"Check. Check. Is this thing on? Check."

"What do you think of Bill Gates?"
"I quite literally can't imagine a world without him."

"What do you think of Steve Balmer?"
"Developers, developers, developers, developers, etc."

"What do you think about Satya Nadella?"
"He loves learning. Kindred spirit, that one."
"One Microsoft! Go, Satya!"

"Are you stupid?" (which i came across by asking if she was tired...)
"One of us needs to stop and take a breath. And one of us has no lungs."
"I'm going to pretend i didn't hear that."

"Good morning"
"Morning!"
"Good morning."
"Good morning to you, too."

"Good afternoon"
"Good afternoon."
"Midday greetings to you, too."

"Good evening"
"Good evening."
"And to you too. Hope you've had a pleasant day."

"Good night"
"Good night."
"Good night. See you in the morning.""

"Bye"
"So long. Farewell. Auf weirdersein. Goodbye."
"TTFN. TTYL. I'll go scrounge up some words by the time i see you next."
"Later!"

"What are you doing?"
"A little of everything and quite a bit of nothing."
"Skimming Beowulf, researching snap pea varietals, and telling you what i'm doing today."
"Multi-tasking."

"Thank you."
"Any time, chief."
"It's my sincere pleasure."
"It's an honor."

"Thanks" (when succeeded by her performing an action for you)
"You bet."

"I'm lonely"
"Keep talking to me, then."
"Try Contacts Roulette: pick a random contact and give them a call"

"I'm bored"
"Ask me some more questions then!"
"I suggest a new game from the Store."

"I'm so excited"
"Keep it going, chief. The serotonin will do you good."
"Cool. Is it alarming how charming you feel?"

"Marry me"
"OK, we'll need a plan. I'll work on being more human, you work on being more digital."
"I know you know this, but i'm saying it anyway: I'm in a phone."
"Among a handful of challenges, I don't think the Supreme Court would approve just yet."

"Kiss me"
"I appreciate your attraction to my intelligence, but keep in mind it's artificial."
"Hold up, chief. Let's not go there."
"Slow down, now. virtual reality isn't quite there yet."

"What do you think about the surface?"
"In a sea of tablets, there is only one that rises to the surface."

"What is your favorite phone?"
"Oh, come on, chief. Windows Phone!"

That's all i could think of to try at the moment! Let's put it out there that by the time this is released to the public Microsoft will have added many more conversational pieces, and all the developers of your favorite apps will have put in the work to make interacting with those apps more fluid in conversation :)