Error during promotion: "SaaSGrid Guest is not permitted access to standard application databases."

Developer Network

Forums, blogs, and downloads for SaaSGrid developers.

Error during promotion: "SaaSGrid Guest is not permitted access to standard application databases."

  • rated by 0 users
  • This post has 1 Reply |
  • 0 Followers
  • This question was asked by a developer via e-mail and we wanted to share it with the developer community.


    [An] error I
    encountered while deploying the solution to the preview environment was that
    when I tried to get the connection string from inside the service constructor I
    got an exception thrown while [promoting] the application to test status.



    eg. if I do something like this:



        [ServiceBehavior(IncludeExceptionDetailInFaults = true)]

        public class TaskrAdminService : ITaskrAdminService

        {

            public TaskrAdminService()

            {

                DbConnection
    connection = ConfigurationProvider.GetConnection("Taskr");


         
          .....

            }

         .....




    The deployment fails saying that "The following error was reported during
    a staged deployment of the service Apprenda.Taskr.Service.TaskrAdminService :
    SaaSGrid Guest is not permitted access to standard application databases.. This
    error occurred while attempting to start the service."


    Thanks...

    - H

  • H, 

    This message you are getting while unclear (we'll take note of that) is actually the correct behavior and points out something important when developing your services. It is not possible to establish your database connection upon starting of the service, which is what your service is attempting to do. Let me explain a little bit about what is happening to help you understand.

    As a part of SaaSGrid's multi-tenancy features, SaaSGrid shares instances of your database and services for multiple tenants. To know which data to access, a "Tenant Context" is established automatically (based on the logged in user of your application) and passed along with calls to your services.

    When the service is started, there is no request being made to it, so there is only a "guest" Tenant Context in place. The constructor in this case then attempts to establish a database connection, and SaaSGrid's data provider is refusing to do this with the guest tenant context. This is appropriate because there would be no way to know whose data to act upon.

    You'll want to be "stateless" - that is establish a connection and close it for each service call.

    This is a good time to remind you (and everyone!) that services must be completely stateless for the following reasons:

    • One particular instance of your service may be handling requests for many tenants.
    • SaaSGrid may deploy/undeploy/move your services within the cloud as needed.
    • The same service instance will not handle all service calls from that tenant every time.

    The first point is especially important. Consider the example of if you had a static variable that stored your connection. Let's say this variable is initalized the very first time you access the connection. Say Tenant A makes a service call. The database connection would be established as Tenant A. Say Tenant B makes a service call. The connection is already established - but because Tenant A opened it, that tenant's data is returned even though Tenant B made the service call! So this example should demonstrate the reasoning for establishing a fresh connection every time. In fact, SaaSGrid will warn you if you assign fields (i.e. establish "state") in your service.

    Let me know if this makes things clear!

    - Paul

Page 1 of 1 (2 items)