locked
User Login Scenario with Azure Table Storage RRS feed

  • Question

  • Hi guys,

    I am brand new to Azure Table Storage and I am trying to accomplish four main things:

    1. Store multiple entities that references data from each table

    2. Insert data to these tables via front-end forms

    3. Create a user login flow via authentication and authorization using numerous ways to login:

    - Admin Login : using username and password

    - Email Login : using email address and password 

    - Social Login : using Facebook, Twitter, Google + and LinkedIn logins information

    4. Store data received from social media logins into an azure table

    My questions are:

    #1. Is there any sample code that I can utilize to at least guide me in accomplishing the above mentions tasks? I have been looking all over the internet for user login with azure table storage and haven't found a solution. In particular, I would like to use best practices for checking if a user exists in the table via a key.

    #2. I have 3 main entity structure in place and would like to know if they are structured correctly:

    1. Teams
    2. Employees
    3. Administrators

    ..Where an administrator is an employee. My entity structure looks like the following:

    TeamEntity

    public class TeamEntity : TableEntity
        {
            public TeamEntity()
            {
                this.PartitionKey = "Team";
                this.RowKey = Guid.NewGuid().ToString();
            }
    
            public string Name { get; set; }
        }

    EmployeeEntity

    public class EmployeeEntity : TableEntity
        {
            public EmployeeEntity()
            {
                this.PartitionKey = "Employee";
                this.RowKey = Guid.NewGuid().ToString();
            }
    
            public TeamEntity Team { get; set; } //Query by Name or RowKey??
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string TeamName
            {
                get
                {
                    return Team.Name;
                }
                //set
                //{
                //    TeamName = Team.Name;
                //}
            }
        }

    AdministratorEntity

    public class AdministratorEntity : TableEntity
        {
            public AdministratorEntity()
            {
                this.PartitionKey = "Administrator";
                this.RowKey = Guid.NewGuid().ToString();
            }
            
            public EmployeeEntity Employee { get; set; }
            public string UserName { get; set; }
            public string PasswordHash { get; set; }
            public string EmployeeName
            {
                get
                {
                    return Employee.FirstName + " " + Employee.LastName;
                }
                //set
                //{
                //    EmployeeName = Employee.FirstName + " " + Employee.LastName;
                //}
            }
            public string TeamName
            {
                get
                {
                    return Employee.TeamName;
                }
                //set
                //{
                //    TeamName = Employee.TeamName;
                //}
            }
    }

    As you can see, I would like to set a team for an employee and reference the employee's name who is an administrator. Is this the correct way of achieving this functionality?

    Please let me know if I need to explain anything in more details... I would really appreciate constructive criticism and advice asap!

    Thank you for any responses.

    Wednesday, May 23, 2018 2:25 PM

All replies

  • You can check the below link to start with table storage library using .net for common scenarios -

    https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet

    However, I am still not sure what is the main purpose of use table storage.

    What type of data you will be inserting to the Azure tables?

    For login authentication purpose you can use the Active Directory.

    For more information about designing a table storage table please check the link below -

    https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-design-guide


    Please Mark as Answer if my post works for you or Vote as Helpful if it helps you. Kapil Singh

    Wednesday, May 23, 2018 2:39 PM
  • This will help you a lot...

    ElCamino.AspNet.Identity.AzureTable 1.7.0

    "Release Notes

    This project is an open source high performance plugin to ASP.NET Identity framework using Azure Table Storage."

    I use it myself, very easy to use just a few minor changes to using statements and configuration/startup. It includes good examples but let me know if you need a hand.

    • Proposed as answer by vikranth s Sunday, May 27, 2018 12:25 PM
    Sunday, May 27, 2018 5:35 AM
  • Hello Kapil,

    Thank you for your suggestions. I have checked out those links thoroughly before I began testing with code. I already have data being stored into the tables programmatically.

    The main purpose of using table storage was to avoid using 2 types of data stores.

    I have came across active directory and I think that it is the way I should go.


    Regards, Yarrah Ramnarine.

    Monday, May 28, 2018 12:59 PM
  • Hello Steve,

    Thank you for your link. I will check it out and see of it would work for me.

    If I decide to use it and run into any problems, I will ask you for further help. 


    Regards, Yarrah Ramnarine.

    Monday, May 28, 2018 1:02 PM