I am currently trying to activate Azure blob storage for my Web app (I am running NopCommerce 3.70).
I created the storage account on Azure and updated the values of AzureBlobStorage in the Web.config, however nothing seems to happen. The container of the blob is still empty and all thumbs are still being saved under ~/Content/Images/Thumbs.
My config is the following:
<NopConfig>
<AzureBlobStorage ConnectionString="DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey;EndpointSuffix=core.windows.net" ContainerName="images" EndPoint="https://myaccountname.blob.core.windows.net/images" />
</NopConfig>
which is equivalent for Nopcommerce than writing this I reckon:
<appSettings>
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myccountkey;EndpointSuffix=core.windows.net" ContainerName="images" EndPoint="https://myaccountname.blob.core.windows.net/images" />
</appSettings>
Is there anything else to do that I missed?
I'm running a demo site with nopCommerce 3.9 just fine. My config looks similar except the end point part.
Try using this (remove images at the end of endpoint)
<NopConfig>
<AzureBlobStorage ConnectionString="DefaultEndpointsProtocol=https;AccountName=myaccountname;AccountKey=myaccountkey;EndpointSuffix=core.windows.net" ContainerName="images" EndPoint="https://myaccountname.blob.core.windows.net/" />
</NopConfig>
Related
I have an asp.net core deployed to azure, and I am trying to configure logging to my application using the Microsoft.Extentions.Logging interfaces.
currently my app is writing the logs to Log Files folder in the web app storage.
This seems like the right place to log my changes. However, I want to view these logs in a normal interface - downloading a text file everytime, is kinda annoying.
I have looked into application insights, and azure diagnostic logs, but none of them suggest how to work with it using the ILogger interface.
First of all you have to configure logs in your application on Azure:
There is also an option to look at the application console output:
You can also configure Storage on Azure and save logs there (you can configure that in Diagnostic logs section).
If you want to use the Log Stream in an easy way in Azure, you can do this:
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
var sourceSwitch = new SourceSwitch("DefaultSourceSwitch");
sourceSwitch.Level = SourceLevels.Information;
loggerFactory.AddTraceSource(sourceSwitch, new TextWriterTraceListener(writer: Console.Out));
}
TraceListener will ensure that your logs will go to the standard trace output.
You also need to enable stdoutLogEnabled in the web.config (set it to true).
<aspNetCore stdoutLogEnabled="true" />
If you do these two things, you will see all your logs and system logs as well in the LogStream. You can control the level yourself.
P.S. This will work only on Full .NET Framework
P.P.S. I think if you turn on logging to blob under Diagnostic logs setting in Azure, you can have it saved to blob. So everything will happen without you writing any code and manually writing to some location.
I've just found an obscure, yet deeply frustrating, bug with CloudConfigurationManager. I'm looking for workarounds, and also (as a side note) tips about the best forum in which to report the bug. I'm guessing it will be a relatively quick fix.
I've got an Azure app service that connects to DocumentDb with config settings called DocumentDB.Endpoint and DocumentDB.Key. These are picked up in F# with
let endpoint = config.ReadConfigSetting<string>("DocumentDB.Endpoint")
let key = config.ReadConfigSetting<string>("DocumentDB.Key")
The ReadConfigSetting method is a convenience method that performs the relevant type conversions and default assignments. Under the covers it uses CloudConfigurationManager.GetSetting. For our purposes, think of the call as
let endpoint = CloudConfigurationManager.GetSetting("DocumentDB.Endpoint")
let key = CloudConfigurationManager.GetSetting("DocumentDB.Key")
I have a webjob that performs cron jobs on my document DB collections. CloudConfigurationManager picks up the setting from the app service settings first, and if the key is not found in the app service settings, it will look at my webjob's app.config.
In my QA environment, my webjob is picking the correct endpoint, but the wrong key. This is because DocumentDb.Endpoint is listed directly in my app.config file, but DocumentDb.Key is in a separate file that is .gitignored. I don't want sensitive keys in the Git repo, even though it is private, and the credentials are only listed in app.config and my external file as a convenience that lets me run the job locally with a debugger.
So here is my setup:
App.config
<appSettings file="keys.config">
<add key="agentUserName" value="<Everyone can read this>" />
<add key="apiHost" value="<and this>" />
<add key="DocumentDB.Endpoint" value="<points to my remote develpment copy of DocumentDB -- looking forward to when I can get a local repo>" />
</appSettings>
keys.config
<appSettings>
<add key="DocumentDB.Key" value="<This is private, so it's in this gitignored file>" />
<add key="agentPassword" value="<I'm not telling you>" />
<add key="TestUserPassword" value="<I'd be an idiot to post this value in a SO question>" />
</appSettings>
You can see what's happening.
Expected behaviour of CloudConfigurationManager when looking up the value of DocumentDB.Key
Look at the underlying app serice settings for a value of DocumentDB.Key
If it exists, use that.
Otherwise, look in App.config.
If it's not there, look in keys.config.
Actual behaviour of CloudConfigurationManager
Is there a value in keys.config?
If so, use that value.
Then look at the app service settings
Then App.config.
The best workaround I have right now is to comment out the value in keys.config when I publish the web job, but that's clunky. Are there any better ways of doing this?
And where is the best place to log this issue?
Have you looked into Azure Key Vault? Here is an intro to Azure Key Vault: https://azure.microsoft.com/en-us/documentation/articles/key-vault-get-started/
If you store DocumentDB secrets in the Azure Key Vault, you can grant the access to the secrets to the application level. Here is another article that shows how to do it inside a web application: https://azure.microsoft.com/en-us/documentation/articles/key-vault-use-from-web-application/
Hope that helps.
Thanks.
Lengning
Entry level web developer here, thank you in advance.
A very basic single page website starting from Empty ASP.NET Web Application adding each and folder file from scratch. Everything works fine locally bare bones. I'm trying to configure the start page in the subfolder "html" to the file index.html. I get the default "This website has been successfully created" after publishing. Azure web service is working fine because I can go to site.azurewebsites.net/html/index.html to see my page after it's published.
Right clicking the project and going to properties to set as start page, or going to Properties>Specific Page doesn't work as suggested here for deployment but works fine locally. Altering the web.config file as suggested here gives me an internal server error that is fixed once I remove the code
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="html/index.html"/>
</files>
</defaultDocument>
</system.webServer>
I tried different variations of this all with the same internal server error. Is my syntax correct?
I then created a global.asax file and changed the Application_Start line as suggested here:
protected void Application_Start(object sender, EventArgs e)
{
Response.Redirect("/HTML/index.html");
}
Same result.
Lastly, I created an App_Code folder with a RedirectHandler.cs file as suggested by Rion Williams's last suggestion (first link) along with his code and sure enough I get the same result.
"This web app has been successfully created" after publish but I see my desired start page after adding /html/index.html to the end of the url.
Understanding how basic this problem is I took extra care to exhaust as many google searches as I could find relating to the topic before asking this question. My first question on StackO so my reputation is too low to link each page I found. My next attempt is to just start a brand new MVC project and painstakingly rearrange every single file that way. I'm confident that will work but I didn't want to leave this simpler method without learning from what I did wrong especially when I know the answer is going to derp-slap me in the face.
Have you tried to configure the default document under the configuration tab for your website in Azure portal?
With a lot of changing file locations around, clearing cache, and rebooting to avoid server and runtime errors, #hernandgr had the simple option I hadn't known about (shame on me) and funny enough couldn't successfully google about.
It turns out that I didn't need to do any of the steps I had tried to configure the start page beyond just changing it in the configuration tab in the Azure Management Portal. I deleted the global.asax file and the App_Code folder completely, didn't need to touch the web.config in any way and didn't need to implement MVC.
One thing to be noted was that making index.html my start page through Azure seemed to push it up a directory so my CSS, JS, LESS, fonts, and images folders had to be moved up as well to display the page properly.
I have Create an Application in MVC which is currently using AWS Data Server.For it I am using Amazon Simple DB API . My Database Created by the client is allocated at US-EAST-1 but by the code it's accessing the Database US-WEST-2.
If I am Creating the Database or Table Pro grammatically by the code like-
simpleDBClient.CreateDomain(new CreateDomainRequest() { DomainName = "DemoTable"});
it also stores in US-WEST-2 Region.Please let me know how come i retrive the AWS US-EAST-1 Tables.
and in the starting I have also choosed the US-EAST-1 at the time of Creation of Project in Visual Studio. Any Help will be Appreciated.
Check out this blog post from the .NET team on using regions and the .NET SDK. In essence,if you are using V2 of the SDK you can modify you app.config or web.config to look like this:
<configuration>
<appSettings>
<add key="AWSRegion" value="us-east-1"/>
</appSettings>
</configuration>
I have 2 asp.net mvc2 projects in a solution. One is normal site for visitors use and the other one is admin back-end which is going to be separated by sub-domains like test.com and admin.test.com. The scenario is like admin will add a new item(e.g product) with image and test.com will use that image to display product. Both application are sharing one db. so there is no problem to get the item details that is coming from the db. but for item image that has been uploaded in admin directory(admin.test.com) - any idea how to get it from general domain(test.com) to display??
Also what is the best way of separating the resources like image files or even css or js files across sites and how to access them?
p.s.I'm using shared hosting.
Thanks!
You can upload to a third sub-domain or to the front end domain.
You upload to a physical folder. This folder can be an appSetting value or so.
So, you get similar settings to those in web.config appSettings:
<add key="ProductImagesPhysicalFolder" value="x:\websites\frontend\product-images" />
<add key="ProductImagesFolderUrl" value="http://frontend.com/product-images" />
Upload to the physical folder (given you setup permission in ISS to allow write access to that folder), and have a helper method like GetProductImageUrl(string imageFilename) to get the URL of the image given its filename (saved in DB).