Blazor Azure WebApp Wont Start - Socket Exception 10013 - Works Fine on Home Server - c#

I have a home server and deploying blazor on it works without issue. Im running windows 11 on the home server - dedicated pc. When I try to deploy to azure webapp it deploys just fine. But when I try to start the .exe i get this error. enter image description here
Im using kestrel from MS.
builder.WebHost.ConfigureKestrel(options =>
{
options.ConfigureHttpsDefaults(httpsOptions =>
{
httpsOptions.SslProtocols = SslProtocols.Tls13;
});
options.Listen(IPAddress.Any, 443, e =>
{
e.UseHttps("######.pfx", "#######");
e.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
});
});
I tried everything. Spent hours on this issue.
Please help. Thank you.
I tried everything!!!

Related

ASP.NET Core 6 MVC app hosted on one server trying to access a remote Directory on another server throws 500.30 error

This bounty has ended. Answers to this question are eligible for a +50 reputation bounty. Bounty grace period ends in 22 hours.
whisk is looking for an answer from a reputable source.
I created an image uploading app for a client and they want to host it on its own IIS server. When I publish the app to the server I get the error
HTTP Error 500.30 - ASP.NET Core app failed to start
I have installed all the .NET v6 SDK, Runtime and hosting bundle that is needed to host the app.
After looking around on SO and google I was able to run the appNameHere.dll from the command prompt and it runs just fine without showing any errors. When I do that I can open it locally on the server and have the app show up. It's just when it's public facing I get the error.
I have narrowed it down to these few lines of code in the Program.cs file
app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(Path.GetFullPath("\\\\12.34.56.789\\c$\\ABC\\FolderName\\ProjectName\\Images\\ItemImages\\")),
RequestPath = new PathString("/ItemImages")
});
When I comment these out, the app shows up fine and works, but I can't get the files from the other site.
I can also set up a folder locally in the "C:\UnitImages" and everything works as well.
I created a shared connection to the main server to test the path as well and it works there too. So I'm a bit lost on where to go next.
Update
As stated in one of the links from #Code Maverick I have updated the Application Pool Identity to the user that has full access to the folders and I still get the Error that's stated above.
I came across this article and tried it but I'm getting an error 'NetworkConnection' is a namespace but is used like a type
repo for ref.
var sourceCredentials = new NetworkCredential { Domain = "12.34.56.789", UserName = "Administrator", Password = "123456" };
using (new NetworkConnection("\\\\12.34.56.789\\c$\\ABC\\FolderName\\ProjectName\\Images\\UnitImages\\", sourceCredentials))
{
// to serve static froms from \\network\shared location
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(Path.GetFullPath("\\\\12.34.56.789\\c$\\ABC\\FolderName\\ProjectName\\Images\\UnitImages\\")),
RequestPath = new PathString("/UnitImages")
});
}
Based on this and this, you may need to provide IIS_IUSRS group the ability to write to the share.
You personally may be able to access the share, but your web application hosted within IIS needs the same access privilege. This does have security implications though.

ASP.Net Core Web API works on IIS Express, but not working when deployed to IIS

I'm new to ASP.Net Core. I have an ASP.Net Core Web API project through which you can connect to a local MS SQL database and perform CRUD operations for the database. The Web API works just fine when running on IIS Express -- it launches the Chrome browser, retrieves records from the local SQL database, and displays the values on the Chrome browser. But the problem is, the Web API does NOT work when deployed to IIS (that is, when published to a folder and being run on IIS.)
I guess the problem is about connecting to the MS SQL database. I'm suspecting that connecting to the database works fine on IIS Express, but fails to connect when deployed to IIS for some reasons. But I'm not sure. The following is the connection string:
// Connection String=> "Data Source=.\\SQLEXPRESS01;Initial Catalog=mynotedb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddMvc(option => option.EnableEndpointRouting = false)
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
services.AddDbContext<mynotedbContext>(options => options.UseSqlServer("Data Source=.\\SQLEXPRESS01;Initial Catalog=mynotedb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"));
}
I have an identical SQL database copied on my Azure account, and the web API works just fine for the Azure SQL database. It works fine both when run on IIS Express and deployed to IIS when it connects to the Azure database. For the Azure SQL database, the connection string is as the following:
services.AddDbContext<mynotedbContext>(options => options.UseSqlServer("Server=tcp:mynote1.database.windows.net,1433;Initial Catalog=mynotedb;Persist Security Info=False;User ID=mylogin;Password=mypassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"));
Please help me with this issue. I've been trying to find the solution for the whole day with no success. Thank you in advance!
first step check database connection work currently and TrustServerCertificate=True
next step check permission folders on your host or your service provider

How do I troubleshoot Microsoft.Windows.Storage.StorageException:The remote name could not be resolved

I am troubleshooting why a particular computer started getting this exception yesterday with code it regularly runs.
I created the following test to reproduce the problem
var account =
CloudStorageAccount.Parse(
$"DefaultEndpointsProtocol=https;AccountName={accountName};" +
$"AccountKey={accountKey}");
var client = account.CreateCloudBlobClient();
var conref = client.GetContainerReference(containerRef);
var blobref = conref.GetBlockBlobReference(filename);
blobref.DownloadToFile(fullDownloadName, FileMode.Create);
On a good pc running windows 2012 Server Release 2 ,the file downloads
On the bad pc running windows 8.1 only a zero length empty file creates
I rebooted the bad PC.
What else can I try?
both pcs have internet access.
Console.WriteLine($"DefaultEndpointsProtocol=https;AccountName={accountName};" + $"AccountKey={accountKey}")
looks the same on both pcs.
The test console app references WindowsAzure.Storage 9.3.2
I am installing the console app via file copy.
Here are the files
[Update]
I am trying to install the client tools from https://learn.microsoft.com/en-au/cli/azure/install-azure-cli?view=azure-cli-latest
I have a this site can't be reached error.
We changed the local DNS to 1.1.1.1
then ran IPConfig /flushdns
then my test started working.
However having the DNS server not be the domain server was problematic ( access errors )
So then we changed the local DNS back to the domain server and set the secondary DNS to 1.1.1.1
Rebooted the domain server and the box

Azure database randomly stopped working after publishing UWP app

Ive made an app that uses Azure easy tables and connects using the following:
try
{
await ctv.combatDrillsTable.Initialization;
await ctv.combatDrillsTable.InitLocalStoreAsync();
await AddItemsAsync();
}
catch
{
var addError = new MessageDialog("Connection to your drills could not be established at this time, returning to " +
"main menu");
await addError.ShowAsync();
if (MainPage.MyFrame.CanGoBack)
{
MainPage.MyFrame.GoBack();
}
}
This was doing a GET request fine the last few weeks but now the connection error throws, I checked my Azure portal and the drills are there, the server overview shows the following:
HTTP Error stats
Im not really sure whats wrong and why Azure has just decided to stop working. I get the same results on bith my local machince is Visual Studio 2017 and the app installed on windows from the store.
Im not really sure whats wrong and why Azure has just decided to stop working.
Firstly, you need to enable logs in Azure, in that case you could access the information logged by Azure and check the logs to find the detail reason. Details for how to do please reference this article.
Since you're using easy table, the azure backend should be node.js. After enabled logs, you could access logs by address like: https://{your app name}.scm.azurewebsites.net/api/vfs/LogFiles/Application/index.html.
If you still cannot resolve your issues by checking the log details, you could upload the log for further looking.

Programmatically creating a remote site in IIS7 using Microsoft.Web.Administration: Invalid index. (Exception from HRESULT: 0x80070585)

I'm trying to write a provisioning tool for our web application. I am attempting to create a web site remotely in IIS7.5 using Microsoft.Web.Administration.ServerManager.
CODE:
using (ServerManager serverManager = ServerManager.OpenRemote("MyRemoteHost")) {
serverManager.Sites.Add("Contoso", "http", "*:80:www.contoso.com", #"C:\inetpub\wwwroot\Contoso");
serverManager.CommitChanges();
}
The above code continuously fails with error: Invalid index. (Exception from HRESULT: 0x80070585)
NOTES:
If I run this code locally on the host, I do not encounter the error and the web site is created successfully.
My user has administrative privileges on the remote host.
I am able to perform other operations on the remote host such as reading the listing of sites.
My workstation is running Windows 8
I've managed to successfully execute the above mentioned code against a Server 2012 host. There appears to be some sort of incompatibility when running this code on a Windows 8 client against a Server 2008R2 host.
I'm using Microsoft.Web.Administration.7.0.0.0.
Any help in resolving this issue would be greatly appreciated.
Thank you
I was having the same issue too by using a remote serverManager object connected to my target server on a very large, heavily regulated corporate network.
After some investigation however, it turned out that the website WAS being created on that specific instance of server manager and, despite the error comming back, using the .CommitChanges(); method on that serverManager object would succesfully save the new website.
var serverManager = ServerManager.OpenRemote("ServerName");
var sites = string.Join(";", serverManager.Sites.Select(o => o.ToString()));
Console.WriteLine(sites);
try
{
serverManager.Sites.Add("newWebSite", #"D:\TestSite", 80);
}
catch ( Exception e )
{
Console.WriteLine(e);
}
Console.WriteLine(string.Join(";", serverManager.Sites.Select(o => o.ToString())));
Console.WriteLine(string.Join(";", ServerManager.OpenRemote("ServerName").Sites.Select(o => o.ToString())));
serverManager.CommitChanges();
Console.WriteLine(string.Join(";", ServerManager.OpenRemote("ServerName").Sites.Select(o => o.ToString())));
Console.ReadLine();
Using this sample code, the catch was not hit, indicating that the program still worked and I can clearly see the website added to the remote server in both the original instance of the serverManager and the new one I created.
The Console returned this:
CopyOfLive;Default Web Site
CopyOfLive;Default Web Site;newWebSite
CopyOfLive;Default Web Site
CopyOfLive;Default Web Site;newWebSite
Furthermore, checking IIS on the server proved that the website had been created.
I hope this helps!

Categories