none
Cannot Host PivotViewer app on Azure

    Question

  • I'm trying to host a small PivotViewer app on Azure, so that co-workers can access it from home and abroad, but I haven't been able to get it to work.  I've got the pivot working locally, and I've imported that project into an Azure project, but when I compile it it gives me the URL of my CXML across the top of the screen and nothing else.  It looks like it can't find the CXML file, but I can't figure out why not.

    Has anyone tried to do something similar?  Does anyone know of a good tutorial for getting this to work?

    -Brett

    Tuesday, March 15, 2011 3:41 AM

Answers

  • I recommend you install and run Fiddler2 - the HTTP Debugging Proxy. It will show you all the HTTP requests being made.

    My guess is that you'll see some 404 Statuses on the .cxml file and maybe the .xap file that comprise your Pivot data and application.

    The reason for my guess is that in your steps above you didn't mention setting the Build Action of the .cxml file to "Content".

    Without this, when Azure Tools packages you application for deployment (inc to the Emulator), the files will be missed.

    I did 4 things only to get a non-Azure pivot example to work locally:

    1. Add an empty Azure Project, Add a Role in Solution pointing at the Web Role in question
    2. Set build action to Content on .cxml and .xap objects
    3. Add clientaccesspolicy.xml
    4. Add mime-types to web.config

    All worked for me at this point. I see from your summary that you didn't list number 2.

    Also, number 5 won't work unless you have a deployed app in product, or the url for your cxml is in blob storage. Did you try the dynamic setting using .aspx file?

    One other point, your 403 error may be for accessing the root application. Try typing in the actual file name of your .aspx page.

    Andy

     


    http://blog.bareweb.eu
    • Marked as answer by BrettBowman Saturday, March 19, 2011 12:14 AM
    Thursday, March 17, 2011 9:17 AM

All replies

  • Hi Brett,

    We cannot simply add the existing ASP.NET project to an Azure project without any extra work and expect it works well. The cloud environment is different from a single web server. Since the Windows Azure Platform might host a single app in more than two instances (like two separated servers) and also the storage is cloud based (the local file system is not a good place to store files now), we need the migration between ASP.NET to Windows Azure.

    These resources will assist you on the migration:

    Migrating an Existing ASP.NET App to run on Windows Azure

    How Do I: Migrate my Existing ASP.NET Application to Windows Azure?

    Thanks.

    Tuesday, March 15, 2011 9:17 AM
  • Brett,

    I am not sure what type of application this is but it sounds like the application needs to access some file or files stored locally.  One option would be to create a VM with your application installed and deploy to the VM Role.  The other option could be to modify your code by storing the CXML file in blob storage and have your code pull from blob storage when it needs to read the file.  Again I making a ton of assumptions here.  Finally, in addition to the links already provided I would download the Windows Azure Training Kit.  http://www.microsoft.com/downloads/en/details.aspx?FamilyID=413E88F8-5966-4A83-B309-53B7B77EDF78&displaylang=en

    Thanks,

    Apollo

    Tuesday, March 15, 2011 1:45 PM
  • I figure it is failing the files as well - apparently Azure isn't fond of /localhost/.  Storing the CXML in blob storage and accessing it from there seems like my best bet, but I'm a biologist not a web designer.  Could you suggest some good tutorials on how to upload data to/access it from blob storage?

    -Brett

    Tuesday, March 15, 2011 5:05 PM
  • Right, I know that I can't just copy the code and run in on Azure.  However, I have successfully migrated my HelloWorld app to Azure and gotten that to work, in addition to the fact that my migrated pivotviewer does generate a website with the URL of my CXML file listed at top (even if the rest of the screen is blank) tells me that the core part of my website is making the transition.  It's just not finding the CXML via /localhost/, so I need an alternative.

    -Brett 

    Tuesday, March 15, 2011 5:09 PM
  • Hi Brett,

    You need to make sure that the Windows Azure tools package up the "content" parts of your PivotViewer project. Make sure the cxml data in your ClientBin (I'm assuming that's what you're trying to load) is set to build action "Content" and "Copy Always" or "Copy if Newer". Do the same with the XAP file in the same place.

     

    Add this to your web.config:

     

        <system.webServer>

          <staticContent>

            <mimeMap fileExtension=".cxml" mimeType="application/xml" />

          </staticContent>

        </system.webServer>

     

    This will get the cxml being served through IIS and Azure. 

     

    However, the sample I'm using is still facing problems (I'm not PivotViewer expert!). I'll post any more details I find.

    Andy

     

     


    http://blog.bareweb.eu
    Tuesday, March 15, 2011 8:48 PM
  • One last thing, add a file at the root of the WebRole called ClientAccessPolicy.xml:

     

     

    <?xml version="1.0" encoding="utf-8" ?>

    <access-policy>

      <cross-domain-access>

        <policy>

          <allow-from>

            <domain uri="*" />

          </allow-from>

          <grant-to>

            <resource path="/" include-subpaths="true" />

          </grant-to>

        </policy>

      </cross-domain-access>

    </access-policy>

     

     

    This now works for me.

    The problem is with accessing the Web Server on a different port.

    Now as promising as this sounds, this solution may not work on Azure - it's one to check. As pivotviewer loads it requests resources on the local IIS's port, which can be different to the Azure endpoint port - which is actually a load balancer port. If this is the case (it may just be a local thing) then these requests won't work as the local IIS port is not internet facing in Azure.

    Andy


    http://blog.bareweb.eu
    Tuesday, March 15, 2011 9:00 PM
  • I've successfully served pivotviewer collections from Azure - including from Azure Blob storage.

     

    In addition to the .cxml mime type, you also have to add mime types for the deep zoom (dzc and dzi) files.

     

    Plus, if you are serving from Blob storage then you have to use the anonymous root container to store the cross domain policy file.

    Tuesday, March 15, 2011 9:09 PM
  • Right, I know that I can't just copy the code and run in on Azure.  However, I have successfully migrated my HelloWorld app to Azure and gotten that to work, in addition to the fact that my migrated pivotviewer does generate a website with the URL of my CXML file listed at top (even if the rest of the screen is blank) tells me that the core part of my website is making the transition.  It's just not finding the CXML via /localhost/, so I need an alternative.

    -Brett 

    I'm a bit worried about your "/localhost/" link here - you definitely need to replace the /localhost/ link with a full URL to the CXML on Azure.

    (Aside - just checking - hoping this doesn't sound insulting - but do you understand what localhost is? Localhost is the address of the loopback on your current PC - so it's only for use in testing and development - localhost can *not* be used on a live server.

    If you already understood that, then feel free to ignore me - or to teach me some stuff about biology!)

    Tuesday, March 15, 2011 9:31 PM
  • I'm a bit worried about your "/localhost/" link here - you definitely need to replace the /localhost/ link with a full URL to the CXML on Azure.

    (Aside - just checking - hoping this doesn't sound insulting - but do you understand what localhost is? Localhost is the address of the loopback on your current PC - so it's only for use in testing and development - localhost can *not* be used on a live server.

    If you already understood that, then feel free to ignore me - or to teach me some stuff about biology!)

    @slodge:  Right - that's sort of my problem.  I was pretty sure that /localhost/ wasn't the way to go about it, but I couldn't figure out what other way to do it.  A lot of the more advances samples get their collection from a setting in InitParam for example, but no one explains how to set it up that way or why.  In addition, there are a some examples that access collections stored in Blob Storage, but no good explanation of how to get it there.  I was hoping that one of the experts on this forum could point me in the right direction, and tell me where I can find good tutorials/explanations of how to do these things.

    @Andy Cross: Yep, made those changes back when it was local - those same bits of code crop up in almost all of the PivotViewer tutorials that I've seen.

    Man, this stuff makes tissue culture look easy by comparison!

    -Brett

    Wednesday, March 16, 2011 2:14 AM
  • Ok so your are either running a HTML or ASPX page in order to launch your Silverlight application. Visual Studio will have created both of these for you. If you're running the HTML version, you'll have difficulty in changing the InitParam dynamically, if you're running the ASPX version then you can modify it at runtime (as it gets rendered by the server).

    You have 2 choices - host the files INSIDE your WebRole (like you have it if you followed a similar process to what I suggested) or host the files in blob storage. There are other options (host the files elsewhere) but I'll ignore those and go with a simple Azure solution.

    If your files are hosted INSIDE your WebRole, your challenge is to determine their location when they are deployed to Azure. Your HTML file will say initParam=http://localhost/clientbin/blah.cxml. That won't work as localhost will refer to the CLIENT machine, and it is very unlikely that that file exists and if it does, it won't be the file you intend. Instead, you need to use an absolute url to the Azure based file. You have the option of using a production slot only (http://yourAccountName.cloudapp.net/clientbin/blah.cxml) and that url will always resolve. This isn't ideal as it means any future updates to staging will use live data. It would work as a fudge however. What you really need is to have the initParam say something like http://{staging-guid}.cloudapp.net/clientbin/blah.cxml when in staging, and http://yourAccountName.cloudapp.net/clientbin/blah.cxml when in production. This is where the ASPX page can help out.

    If you mark the <param name="initParam" .. /> as runat="server", you can programmatically access it and update its value attribute to include Request.Headers["Host"] or Request.Url.HostName (note the first is the public facing url, the second may not be).

    You could achieve the same thing with inline code <param name="initParam" value="<%= Request.Headers["host"] %>/clientbin/blah.cxml" />

    That's your first option.

    The second is to put the blah.cxml file into blob storage. Use something like Cerebrata Cloud Storage Studio link or Windows Azure Storage Explorer link to put the file into a public container in blob storage, and then put the public absolute URL into the value for the initParam.

    As for tutorials, both of those links have examples as to how to use those products. There are lots of examples for azure and silverlight - just google or bing it.

    Andy


    http://blog.bareweb.eu
    Wednesday, March 16, 2011 8:55 AM
  • @slodge:  Right - that's sort of my problem.  I was pretty sure that /localhost/ wasn't the way to go about it, but I couldn't figure out what other way to do it.  A lot of the more advances samples get their collection from a setting in InitParam for example, but no one explains how to set it up that way or why.  In addition, there are a some examples that access collections stored in Blob Storage, but no good explanation of how to get it there.  I was hoping that one of the experts on this forum could point me in the right direction, and tell me where I can find good tutorials/explanations of how to do these things.

    Hi Brett

    You must be pretty close.

    Assuming you are hosting the PivtoViewwe files within your web role, you just need to  use the InitParam method.

    The way this method works is:

    - in the HTML, the InitParam includes an http:// link to the cxml file - so if you were testing with localhost://pivot/mypivot.cxml and you were then uploading to azure at biology.cloudapp.net, then the InitParam would contain a link to http://biology.cloudapp.net/pivot/mypivot.cxml - e.g.

    <param name="initparams" value="myPivot=<span style="font-family:Verdana,Arial,Helvetica,sans-serif; white-space:normal">http://biology.cloudapp.net/pivot/mypivot.cxml</span>" />
    

    - in the Silverlight PivotViewer code, this InitParam would be picked up - normally in the MainPage constructor:

     

          string initialCollectionUri;
          if (!App.Current.Host.InitParams.TryGetValue("myPivot", out initialCollectionUri))
          {
            // Otherwise this is an application error :/
            ErrorWindow errorWin = new ErrorWindow("Sorry",
              "Nothing to show!");
            errorWin.Show();
            return;
          }
          if (initialCollectionUri.EndsWith(","))
            initialCollectionUri.TrimEnd(',');
          PivotViewer.LoadCollection(initialCollectionUri, InitialViewState);
    
    

    Keep pushing - you will get there :)

    Wednesday, March 16, 2011 9:24 AM
  • Thanks for the suggestions, but I still seem to be having no luck:

    Now I'm getting "403: Access Denied Errors" when I load up my pivot app to the cloud.  In addition, I suspect that I may be missing something else - if all that was wrong was my using /localhost/ instead of the URL of my Azure domain name, then why does my attempt to test it locally also give me a blank screen?

    Perhaps it will clarify matters if I spell out how I got here from my working non-Azure pivot app:

    1) Started with a working Pivot app (with clientaccesspolicy.xml and mime-types set), which like most Silverlight apps has 2 projects - LocalPivot with the XAML and C# code, and LocalPivot.Web with the ASPX/HTML code.

    2) Added a blank Windows Azure project (No Azure roles)

    3) Added LocalPivot.Web to the Windows Azure project as a WebRole

    4) Added a WebRole.cs file copied from another Azure project to LocalPivot.Web, with the appropriate change made for the new namespace/project name

    5) Changed the hard-coded URL for the pivot collection to reflect my Azure domain.

    I've also tried things the other way for the record - starting a fresh Azure project and importing my Pivot code etc. from an existing project, with the same result.

    What else am I missing?

    -Brett

    Thursday, March 17, 2011 12:16 AM
  • I recommend you install and run Fiddler2 - the HTTP Debugging Proxy. It will show you all the HTTP requests being made.

    My guess is that you'll see some 404 Statuses on the .cxml file and maybe the .xap file that comprise your Pivot data and application.

    The reason for my guess is that in your steps above you didn't mention setting the Build Action of the .cxml file to "Content".

    Without this, when Azure Tools packages you application for deployment (inc to the Emulator), the files will be missed.

    I did 4 things only to get a non-Azure pivot example to work locally:

    1. Add an empty Azure Project, Add a Role in Solution pointing at the Web Role in question
    2. Set build action to Content on .cxml and .xap objects
    3. Add clientaccesspolicy.xml
    4. Add mime-types to web.config

    All worked for me at this point. I see from your summary that you didn't list number 2.

    Also, number 5 won't work unless you have a deployed app in product, or the url for your cxml is in blob storage. Did you try the dynamic setting using .aspx file?

    One other point, your 403 error may be for accessing the root application. Try typing in the actual file name of your .aspx page.

    Andy

     


    http://blog.bareweb.eu
    • Marked as answer by BrettBowman Saturday, March 19, 2011 12:14 AM
    Thursday, March 17, 2011 9:17 AM
  • Victory!  It was indeed adding the cxml and associated folder to the project and setting the correct build action that was the issue.

    Much obliged for your help, gentlemen,

    -Brett

    Saturday, March 19, 2011 12:14 AM
  • I recommend you install and run Fiddler2 - the HTTP Debugging Proxy. It will show you all the HTTP requests being made.

    My guess is that you'll see some 404 Statuses on the .cxml file and maybe the .xap file that comprise your Pivot data and application.

    The reason for my guess is that in your steps above you didn't mention setting the Build Action of the .cxml file to "Content".

    Without this, when Azure Tools packages you application for deployment (inc to the Emulator), the files will be missed.

    I did 4 things only to get a non-Azure pivot example to work locally:

    1. Add an empty Azure Project, Add a Role in Solution pointing at the Web Role in question
    2. Set build action to Content on .cxml and .xap objects
    3. Add clientaccesspolicy.xml
    4. Add mime-types to web.config

    All worked for me at this point. I see from your summary that you didn't list number 2.

    Also, number 5 won't work unless you have a deployed app in product, or the url for your cxml is in blob storage. Did you try the dynamic setting using .aspx file?

    One other point, your 403 error may be for accessing the root application. Try typing in the actual file name of your .aspx page.

    Friday, June 29, 2012 1:44 AM