Reputation: 1361
I have created and published an azure function . My solution has one file called abc.json which is being added with function project in Visual studio. I am able to successfully debug my code but when publishing and after deployment , i get error in log file as could not find file abc.json? what wrong am I doing? and how can I fix this? I have right clicked on abc.json and selected "Content" and "Copy Always"
My code:
public static class MyFunctionClass
{
private static readonly string _endpointUrl = System.Environment.GetEnvironmentVariable( "endpointUrl" );
private static readonly string _primaryKey = System.Environment.GetEnvironmentVariable( "primaryKey" );
private static readonly string source_databaseId = "mydb";
private static readonly string target_containerId = "mycollection";
public static Dictionary<string, string> projectCustomerNameMapping =
JsonConvert.DeserializeObject<Dictionary<string, string>>( File.ReadAllText( "abc.json" ) );
[FunctionName( "CopyActivity" )]
public static async Task Run( [CosmosDBTrigger(
databaseName: "mydb",
collectionName: "mycollection",
StartFromBeginning = true,
ConnectionStringSetting = "CosmosDBConnection",
LeaseCollectionName = "leases",
CreateLeaseCollectionIfNotExists = true,
LeaseCollectionPrefix= "testprefix"
)] IReadOnlyList<Document> source,
ILogger log )
{.... my logics..}
Upvotes: 0
Views: 156
Reputation: 2439
Modify the function method and add the additional parameter ExecutionContext context
like below code.
public static async Task Run(<.... Other parameters>, ILogger log, ExecutionContext context)
You can build the path by combining the function directory, and also check the file path and set something like below
"D:\\home\\site\\wwwroot>\\Ini\\Sample.ini"
Check this SO for related discussions.
Upvotes: 1