resolveAsset filter

The documentation mentions the resolveAsset filter in a couple places but not sure how exactly to set it up. I am not using a Sharp App where this is documented, but the SharpPagesFeature and want to setup a CDN using an Azure Blob. Do I just add the Azure to the virtual file system per the docs and this just works?

https://github.com/ServiceStack/ServiceStack.Azure#virtual-filesystem-backed-by-azure-blob-storage

{{ 'site.css' |> resolveAsset }} --> the docs linked above say it will work on localhost by pulling the local file but I’m assuming that when locally I would have to not register the azure cdn? Also, the azure storage may have a different url for the cdn that sits in front so not sure how to actually set all that up using resolveAsset or if I need to make my own script method which I’d prefer not to do if there is something that can be configured.

resolveAsset is documented in the Rockwind VFS example which is only used for resolving references, i.e. by default it returns itself, to have it use a CDN URL you need to set assetsBase (ScriptConstants.AssetsBase) global argument, which can be configured with the args.assetsBase configuration in a Sharp App or can be configured with:

new SharpPagesFeature {
    Args = {
        [ScriptConstants.AssetsBase] = "..."
    }
}

Thanks, I realize I need to create my own type of resolveAsset to handle what I want which is:

  • If the asset is available in the external azure storage return the cdn link (cache the request as it doesn’t need to check again)
  • Otherwise return the internal one

Thanks for the code above, that is helpful.