Hi,
Please see code below:
public class EmailDefinitionTemplateProvider : TemplateDefinitionProvider
{
public const string SubjectPropertyName = "Subject";
public const string DescriptionPropertyName = "Description";
private const string DefaultEmailLayout = "EmailLayout";
public const string NotesPropertyName = "Notes";
public override void Define(ITemplateDefinitionContext context)
{
if (context != null)
{
context.Add(
new TemplateDefinition(
DefaultEmailLayout,
isLayout: true
).WithVirtualFilePath(
$"/Emailing/Templates/{DefaultEmailLayout}.tpl", //template content path
isInlineLocalized: true
).WithScribanEngine()
);
foreach (var emailCode in Enum.GetValues(typeof(EmailCode)))
{
context.Add(
new TemplateDefinition(
name: emailCode.ToString(),
defaultCultureName: CatOsConsts.CultureNameEn,
layout: DefaultEmailLayout //Set the LAYOUT
).WithScribanEngine()
.WithVirtualFilePath(
$"/Emailing/Templates/{emailCode}", //template content folder
isInlineLocalized: false
)
.WithProperty(SubjectPropertyName, L($"MailType:{emailCode}:MailSubject"))
.WithProperty(DescriptionPropertyName, L($"MailType:{emailCode}:MailDescription"))
.WithProperty(NotesPropertyName, L($"MailType:DEFAULT:MailNote"))
);
}
}
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<EmailResource>(name);
}
In the code above we are using the ABP implementation for Template management. The solution works fine locally (in Visual Studio), however after deployment to Azure App Service, we are getting the following error:
Error Message: Could not find a file/folder at the location: /Emailing/Templates/CAT_INV_W
We have traced it back to this line of code above:
).WithVirtualFilePath(
$"/Emailing/Templates/{DefaultEmailLayout}.tpl", //template content path
It appears the virtual file path is not working on Azure, and we are not sure how to fix it. Can you please let us know if there is something we need to configure to allow Virtual File Paths to work with the ABP Framework on Azure?
If you can guide us to the right documentation or help us resolve this issue that would be greatly appreciated.
Thanks,
Jesse
ABP Framework version: v4.4.2 UI type: Blazor Server DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): no Exception message and stack trace:
Error Message: Could not find a file/folder at the location: /Emailing/Templates/CAT_INV_W
Stack trace:
Volo.Abp.AbpException:
at Volo.Abp.TextTemplating.VirtualFiles.LocalizedTemplateContentReaderFactory+<CreateInternalAsync>d__9.MoveNext (Volo.Abp.TextTemplating.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.TextTemplating.VirtualFiles.LocalizedTemplateContentReaderFactory+<CreateAsync>d__8.MoveNext (Volo.Abp.TextTemplating.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.TextTemplating.VirtualFiles.VirtualFileTemplateContentContributor+<GetOrNullAsync>d__3.MoveNext (Volo.Abp.TextTemplating.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.TextTemplating.TemplateContentProvider+<GetContentOrNullAsync>d__11.MoveNext (Volo.Abp.TextTemplating.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.TextTemplating.TemplateContentProvider+<GetContentOrNullAsync>d__9.MoveNext (Volo.Abp.TextTemplating.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter.GetResult (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.TextTemplateManagement.TextTemplates.TemplateContentAppService+<GetAsync>d__5.MoveNext (Volo.Abp.TextTemplateManagement.Application, Version=4.4.2.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Castle.DynamicProxy.AsyncInterceptorBase+<ProceedAsynchronous>d__14`1.MoveNext (Castle.Core.AsyncInterceptor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e33b67d3bb5581e4)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1+<ProceedAsync>d__7.MoveNext (Volo.Abp.Castle.Core, Version=4.4.2.0, Culture=neutral, PublicKeyToken=null)
1 Answer(s)
-
0
Could not find a file/folder at the location: /Emailing/Templates/CAT_INV_W
You can check this https://docs.abp.io/en/abp/latest/Text-Templating-Scriban#the-template-content