Start a new topic
Answered

It is not possible to use FileSystemBlobAssetRepository from system jobs

The following is customer support request from Giedrius:

reason is this method:
private string Absolute(string relative)
{
var filePath = HttpContext.Current.Request.MapPath(relative, _storagePath, false);
return filePath;
}

thing is, that system job is running in separate thread, so HttpContext.Current is null.

Best Answer

By direct i meant using it through the web service, aka IAssetService, similar to how it is used in the commerce manager:


_container.RegisterService<IAssetService>(

_container.Resolve<IServiceConnectionFactory>().GetConnectionString(AssetConfiguration.Instance.Connection.ServiceUri), AssetConfiguration.Instance.Connection.WSEndPointName);


1. Yes, you are right. The system does choose dynamically based on the deployed environment, actually it chooses it based on bootstrapper registrations (which is part of the sample code and not the engine, engine is simply passed the implementation of interface). 

2. We will look into making file system storage provider work using local tests.


Hello Giedrius, you are correct. 


However FileSystemBlobAssetRepository is not meant to be used directly. You should always use IAssetService and this asset service should be used through the web services interface since job scheduler can be running on a separate machine as where the files are stored.

We don't use it directly, but as long as which asset repository is used is not controlled by us (engine chooses depending on AzureCommonHelper.IsAzureEnvironment) when debugging localy it tries to use FileSystemBlobAssetRepository. 

So there are two problems:

1) system chooses storage depending on runtime environment. I think this could be changed to be controlled from configuration, using config transforms users could choose what storage they prefer and where.

2) FileSystemBlobAssetRepository should work regardless from where it is used, as it is transparent for the user - as you said, IAssetService should be used instead, so I should not care about FileSystemBlobAssetRepository implementation. I understand, where this problem comes from, it should be possible to solve it by handling case when HttpContext.Current is null - like trying to search config for path in case HttpContext.Current is null.

Answer

By direct i meant using it through the web service, aka IAssetService, similar to how it is used in the commerce manager:


_container.RegisterService<IAssetService>(

_container.Resolve<IServiceConnectionFactory>().GetConnectionString(AssetConfiguration.Instance.Connection.ServiceUri), AssetConfiguration.Instance.Connection.WSEndPointName);


1. Yes, you are right. The system does choose dynamically based on the deployed environment, actually it chooses it based on bootstrapper registrations (which is part of the sample code and not the engine, engine is simply passed the implementation of interface). 

2. We will look into making file system storage provider work using local tests.

Login or Signup to post a comment