Access Nuget Packages hosted in private Nuget server in Azure Functions - azure

How can I access nuget packages hosted in private nuget server in Azure Functions?. Is there any way I can specify my private nuget server info?
Thanks!

Krishh,
This is possible using a nuget.config file as you normally would:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyPrivateFeed" value="http://myhost/myfeed" />
... other feeds ...
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
Using Kudu, or another deployment method outlined here, copy that file to either the function folder or wwwroot (that would apply to all functions) and your config will be used.

There are several posts related to your question if we assume that your private nuget package can be deployed as a simple .Net library:
Execute pre-compiled .NET code as Azure Function
How do you include references to external assemblies in Azure Functions
How do I use external assemblies with Microsoft Azure Function Apps?
How to put the entry point of an Azure Function inside a .NET DLL?

Related

Does Azure Web App support string/token replacement in config files?

I have a Web App that I deploy via YAML pipeline, but would like to see if it can be done via web app's Deployment Center.
I need to transform the IP address and userPrincipalName in the endpoint element, but it does not fall under AppSettings or connectionstring element. Is it possible to transform this kind of element via Web App, or am I stuck with YAML pipeline?
Here is snippet of my config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="API_AUTH_MODE" value="2" />
</appSettings>
<system.serviceModel>
<client>
<endpoint address="net.tcp://10.0.0.0:99/App1/Services/Service1"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Service1"
contract="Service1" name="NetTcpBinding_Service1">
<identity>
<userPrincipalName value="user#domain.local" />
</identity>
</endpoint>
<endpoint address="net.tcp://10.0.0.0:99/App1/Services/Service2"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Service2"
contract="Service2" name="NetTcpBinding_Service2">
<identity>
<userPrincipalName value="user#domain.local" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Is it possible to transform this kind of element via Web App, or am I stuck with YAML pipeline?
AFAIK, I am afraid you could not transform this kind of element via Web App at this mpment.
That because the IP address and userPrincipalName does not fall under AppSettings or connectionstring element.
So, we could not use the Application settings or connection strings to replace it. We have to resolve this issue with YAML pipeline.
BTW, we could use the Replace Tokens in the YAML pipeline to resolve it.
Hope this helps.
While it was answered correctly above - Web App cannot transform anything other than Appsettings or 'connectionstring`, I ended up doing the following:
Use XML Transform files to replace the strings needed, since there is dependency on build type
Use YAML file to access vault to do password replacements.
I could have used Web App to do the password replacements, but it is much easier to manage the pipeline/deployment/release via a single YAML file rather than split YAML and Web App.

Azure AppInsight not working for static file application

Background
I have an Azure 'App Service' resource and a linked 'Application Insights' resource. They're linked via the App Service's Settings -> Applications settings -> Application settings (key-value table) where I have the following settings:
APPINSIGHTS_INSTRUMENTATIONKEY = <my application insights instrumentation key>
APPINSIGHTS_JAVASCRIPT_ENABLED = true
My application is a static file application at the root / (site\wwwroot) but also has 2 Asp.NET applications at 2 different virtual directories:
/app1 (site\app1)
/app2 (site\app2)
Problem
The overview page shows data for something called 'Metrics' with requests, data, etc. (first image) however when I attempt to access Application Insights, no data appears (second image).
Attemps
I've tried to follow these two guides for activating app insight for static page applications:
http://apmtips.com/blog/2014/12/02/tracking-static-content-with-application-insights-httpmodule/
http://blog.tylerdoerksen.ca/posts/2018/03/AppInsights-Static-Content
However I get an error due to the misisng DLLs in the root Bin folder.
I tried variations of:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"> <!-- With and without 'runAllManagedModulesForAllRequests'. -->
<add name="ApplicationInsightsWebTracking"
type="Microsoft.ApplicationInsights.Extensibility.Web.RequestTracking.WebRequestTrackingModule, Microsoft.ApplicationInsights.Extensibility.Web"
preCondition="managedHandler" /> <!-- With and without 'preCondition="managedHandler"'. -->
<!-- And -->
<add name="ApplicationInsightsWebTracking"
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/> <!-- With and without 'preCondition="managedHandler"'. -->
</modules>
</system.webServer>
According to the second article, these missing DLLs should be automatically loaded by Azure once it knows that it's connected to AppInsight.
If you are using Azure Web Apps. Add the Applications Insights Extension to the Web App. This will add the proper DLLs to the Bin directory of your site.
I tried to follow the instructions under 'Monitor a live Azure web app' but the documentation seems incomplete.
Questions
Why is data showing in the overview of the App Service but not AppInsight?
Is it possible to view website telemetry in AppInsight for my static file application at root /?
1.Why is data showing in the overview of the App Service but not AppInsight?
It should be a configure issue. You can configure it as below:
step 1:
In visual studio, right click your project name, and in the context menu, select "Configure Application Insights".
step 2:
In the following screen, click "Get started".
step 3:
In the following screen, configure your own settings(for Resource, you can create a new or use an existing one).
Then click "Register", and wait for it completes.
step 4:
If some error occurs, just fix it by tips on the screen. like below:
When you have done the above steps, you should see data in App insight(it may take a few minutes for data to display).
2.Is it possible to view website telemetry in AppInsight for my static file application at root /?
Yes, you can view website telemetry in AppInsight for static file application at root /.
step 1:
In the Web.config, find the <system.webServer> node, and then in the <modules> node, add runAllManagedModulesForAllRequests="true", like below:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="TelemetryCorrelationHttpModule" />
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
step 2:
Publish web site to azure.
step 3:
Launch the website to the static file, here I used test4.html for example.
step 4:
Go to azure portal -> your application sights -> Overview section, select a chart like "Server requests"(if no data, please wait for a while).
step 5:
You can see such request "GET /test4.html".

Imageresizer across multiple containers in azure storage

Im uploading images to azure blob storage in a project. For logic reason I'm creating a new container for each upload, to group the content. This park works fine. Now I'm trying to setup ImageResizer to enable resizing :) and som other stuff. In all the examples they point to a container as the endpoint, but in my case I have multiple dynamic container, so this is not an option. My question is if someone knows if it should work in my case or if I need to rethink something about the way I store images.
According to your requirement, you could try to leverage AzureReader2 to work with Azure blobs, in order to dynamic resize your images from Azure Blob. Since you have miltiple dynamic containers, you could follow the steps below to configure AzureReader2:
Install Package via NuGet
ImageResizer.WebConfig
ImageResizer.Plugins.AzureReader2
Web.config
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
</configSections>
<resizer>
<plugins>
<add name="MvcRoutingShim" />
<add name="AzureReader2"
connectionString="{your-storage-connectionstring}"
prefix="~/cloud/" />
</plugins>
</resizer>
<system.web>
<httpModules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</httpModules>
</system.web>
<system.webServer>
<modules>
<add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
</modules>
</system.webServer>
Result
Here is my test, you could refer to it.
1.Upload images to my Azure Blob
https://brucechen.blob.core.windows.net/images01/test.jpg
https://brucechen.blob.core.windows.net/images01/landscape/test.jpg
https://brucechen.blob.core.windows.net/images02/test.jpg
2.Browser images in my web site as follows:
http://bruce-chen.azurewebsites.net/cloud/images01/test.jpg?width=400
http://bruce-chen.azurewebsites.net/cloud/images01/landscape/test.jpg?width=400
http://bruce-chen.azurewebsites.net/cloud/images02/test.jpg?width=400
Note: your images links should look like:
http(s)://<host-name>:<port>/<prefix-you-configured>/<blob-container-name>/<blob-file-name>?width=200&height=200
Additionally, for pre-resizing your images via ImageResizer, you could follow the answer in this thread. Also, there is anther similar library called Simple.ImageResizer which is free, you could refer to it.

Azure SDK, Trace.Information and WADLogsTable

I am writing a new Cloud Service in .NET using Azure SDK 2.5.
I'm aware that there have been some significant changes to diagnostics with the 2.5 SDK rekesae.
Where I am getting conflicting information is whether or not I can still use Azure Diagnostics to capture Trace.* output to WADLogsTable in Azure Table Storage?
I'm aware that I can use ETW as an alternative, but that's now what I'm asking for.
According to this article I can still use Trace to capture my logs with Azure Diagnostics 1.3 - which I understand has shipped with SDK 2.5.
Unfortunately I cannot get it to work.
The app.config of my worker role looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Throughout the code in my worker role I have tracing code that looks like this:
Trace.TraceInformation("Something happened");
My public diagnostics.wadcfg file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageAccount</StorageAccount>
</PublicConfig>
I have used this file to configure the diagnostics service extension using the PowerShell command:
Set-AzureServiceDiagnosticsExtension
No WADLogsTable is ever created.
If I enable other diagnostics services such as Perf Counter then the relevant tables (WADPerformanceCountersTable) are created and populated.
I am using:
Visual Studio 2012
.NET 4.5.1
Azure Powershell (latest v from Web Platform Installer)
Azure SDK 2.5
Can anyone put me out of my misery?
Many Thanks
How are you deploying? On the same setup (VS2012, Azure 2.5 SDK), I only saw the WADLogsTable get created using the Visual Studio "Publish" wizard, which apparently configures the diagnostics extension for you. See:
https://msdn.microsoft.com/en-us/library/azure/dn873976.aspx
Diagnostics configuration must be applied separately after deployment - Because Azure SDK version 2.5 uses the extension model, the diagnostics extension and configuration are no longer part of the deployment package and must be applied separately after the deployment. Visual Studio will apply the extension and configuration for you when you use the Publish wizard to deploy your application [...]
I wasn't able to get the PowerShell cmdlets to work (didn't put much effort into that, honestly) but as a workaround, when I deployed using the VS "Publish" wizard, the WADLogsTable was created and I could see my logs flowing. This didn't happen when I packaged and uploaded through the Azure Portal.
It may be this way for the foreseeable future; the situation doesn't seem to have changed in the 2.6 SDK (though they fixed a lot of the irksomeness with diagnostics in 2.5): https://msdn.microsoft.com/en-us/library/azure/dn186185.aspx
I just created a default worker role that is producing trace logs and I noticed one difference in the public config
<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*" />
</WindowsEventLog>
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageAccount</StorageAccount>
</PublicConfig>

Configure Redis Session State on Azure

I've got the Redis Session State Provider working fine locally with my ASP.Net site and in Azure with my Azure Website. But I've got a question about configuration...
Is there any way to store the configuration for that in the Azure Website itself using the App Settings (or Configuration Strings) section in the Website Properties screen?
That would be very convenient because it would mean that I don't have to modify the web.config file when I publish. I already do this for connection strings and app settings, but I just don't see a way to do that for anything in the <system.web> node of the web.config file, like the <sessionState> node.
There isn't a way to change the behaviour of the provider-based session state from utilising the web.config file.
You could write your own provider and modify where it finds the connection details from so you can publish those details somewhere other than in the web.config, but this wouldn't be standard behaviour.
This question has the way to make this work.
<appSettings>
<add key="REDIS_CONNECTION_STRING" value="[your dev connection string]" />
</appSettings>
<system.web>
<sessionState mode="Custom" customProvider="RedisProvider">
<providers>
<add name="RedisProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="REDIS_CONNECTION_STRING" />
</providers>
</sessionState>
</system.web>
Then, in the portal, you can create an app setting with the name 'REDIS_CONNECTION_STRING' with the correct connection string. You cannot use connection strings section of web.config or azure portal. It must be app settings. Not sure why, but connection strings just uses whatever is in the web.config and is not replaced with what is in the portal.

Resources