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
Get-AzureRMSubscription | Sort SubscriptionName | Select SubscriptionName
Get-AzureRmSubscription –SubscriptionName $subscr | Select-AzureRmSubscription 
Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate 
Get-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicInfrastructureMigrate

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


# 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

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

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

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! :)