I do have a C# ASP.NET Web API on .NET Framework app running perfectly fine on local machine. However, when I deploy this to Azure Web App Service, and when attempting to access one of the endpoints, I am getting an error:
What I am not understanding is where the folder
\api\print
in the error coming from? My endpoint is doing two things:
- Create a PDF file. This is working fine since I can see the created file in the
wwwroot\app_data
folder - Upload the created PDF file to Google Drive. This is where the code is failing. I am suspecting because the app can not open the file.
Below is the code for the actions above:
public GoogleDrivePDFFile CreateTicket()
{
//directory for created files as per stakeoverflow question https://stackoverflow.com/questions/1268738.
string tickets_path = HostingEnvironment.MapPath("~/App_Data/");
//current date and time
var current_date_time = DateTime.UtcNow;
string google_file_name = string.Concat(
current_date_time.Year,
current_date_time.Month,
current_date_time.Day,
current_date_time.Hour,
current_date_time.Minute,
current_date_time.Second,
"_", "XXXX",
".pdf"
); //the filename to use for the new created file
//full path for the new file in the filesytem
string filName = Path.Combine(tickets_path, google_file_name);
//file is being created okay in the filesystem. I can see it in Azure app file system.
PdfFormatProvider provider = new PdfFormatProvider();
using (Stream output = File.Open(filName, FileMode.CreateNew))
{
provider.Export(document, output);
}
GoogleUploads googleUploads = new GoogleUploads();
//It is failing here.....
var returned_file = googleUploads.UploadTicket(google_file_name, filName, requiredDocument);
/*
* I have tested the endpoint with the below and this works fine.
*
var working_example = new GoogleDrivePDFFile();
working_example.DocumentId = "Document ID .... okay";
working_example.DownloadLink = "Download Link .... okay";
working_example.WebViewLink = "Web View Link .... okay";
return working_example;
*/
return returned_file;
}
I am not sure what am I doing wrong.