Alternative options to upload files to Microsoft Azure using Asp.net 3.5 (latest Azure Storage libraries not compatible)? - file-upload

I installed Windows Azure Storage SDk from nuget. Added the references to my project.
When I make the following reference in my code:
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
I get an exception of: the type or namespace 'WindowsAzure' does not exist in the namespace 'Microsoft (are you missing an assembly reference)'?
researching the issue, I read in this blog that it targets 4.0 framework:
http://www.milosev.com/index.php/93-azure/252-the-type-or-namespace-name-windowsazure-does-not-exist-in-the-namespace-microsoft-are-you-missing-an-assembly-reference
I want use the Azure storage to upload files, is possible to do it with net 3.5? Any alternatives, my site is hosted on Azure?

The blog post you reference is really saying that you cannot target the Client Profile. Make sure your project target Framework is .NET 3.5 and not .NET 3.5 Client Profile.
It can definitely work in .NET 3.5. We use Azure storage in a project that targets .NET 3.5.
If that is not the issue, with the latest Azure Storage client, does it include binaries for .NET 3.5? If not, you may have to download and install and older version.
http://azure.microsoft.com/en-us/downloads/archive-net-downloads/

Related

Is NLog.Redis supported on .NET Core?

My previous project which is written on .NET Framework is using NLog.Redis to log information and visualize it on Kibana through Logstash. Is NLog.Redis supported on .NET Core to use in my new project?
Currently there there is no .NET Standard (and so .NET Core) version released.
There is an open pull request for it, see https://github.com/richclement/NLog.Redis/pull/7

Could not load file or assembly 'AutoMapper' in .net project

Could not load file or assembly 'AutoMapper, Version=6.1.1.0,
Culture=neutral, PublicKeyToken=be96cd2c38ef1005' or one of its
dependencies. The system cannot find the file specified.
I have two projects: Azure Function Project and Library project. The library project is where the database tables, context defined in it which running .Net Core 2.0 whereas the Azure Function Project run on .Net Framework 4.6.1.
The error occurred when calling the
db.ExecuteProcedureQuery<ApiAttendanceModel>(StoredProcedureName.Sp_GetAttendanceByAttendanceId, out error, parameterList).SingleOrDefault();
Does anyone know what the issue is?
Inside the azure function (trigger by queue), tried to connect to azure table in the code. It fired and exception. So I changed the project back to .net standard 4.6.1
AFAIK, Microsoft.NET.Sdk.Functions depends on Microsoft.Azure.WebJobs which would depends on WindowsAzure.Storage.
Per my test, I could leverage the client SDK to work with Azure Table storage under my Azure Functions v2.
If your Azure Function targets .NET Framework v4.6.1, after you references the Net Core 2.0 class library, your Azure Function project would retrieve the compile errors as follows:
For your scenario, I would recommend you create a class library targets the .Net Standard that allows your library to be called by your Azure Functions v1 (.NET Framework) or Azure Functions v2 (.NET Core). Details you could follow Building a .NET Standard class library with C#.
Moreover, I just created my .Net Standard 1.3 class library to test this issue. You need to choose which .Net Standard version to be targeted, details you could follow here.

fully compatible powerbi.api package with aspnetcore?

i was able to get the sample asp.net embedded powerbi to work with my reports
now i have to migrate it aspnetcore
i was hopeful when i saw this post - seeing that someone was able to get it done
Embed Power BI Report In ASP.Net Core Website
so i:
started a new project with the aspnetcore
installed the powerbi package
now when compiling im getting this warning:
Package 'Microsoft.PowerBI.Api 2.0.11' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
i searched and couldnt find a powerbi package that was specific to aspnetcore
is there one? will there be a conflict crossing cores? or does it not matter?
UPDATE:
4.6.1 powerbi package does indeed work with aspnetcore 2
but looking forward to a powerbi package specifically coded for core
As you can see this is just a warning, not an error. That warning appears because .NET Core 2.0 applications can use some Nuget packages which target .NET Framework 4.6.1 (or less). However, this inclusion might fail if the referenced .NET 4.x package contains some API not included into .NET Core/.NET Standard 2.0
So, my advice - try to run your application. If it works well at the first glance - then, most probably that PowerBI package does not contain any not supported APIs and will work well further. If it fails right at start - then you will need to wait for the release of the new version of that package which targets .NET Standard 2.0.

Referencing .NET 4.7.1 library using Azure Storage from ASP.NET Core 2 MVC App

In my solution I have an ASP.NET Core 2 MVC app using Razor pages, a Web API 2 app and a .NET 4.7.1 class library containing services and their definitions that use Azure Table Storage from the Azure Storage NuGet (v8.7.0). I'm using autofac for dependency injection.
I have hooked up both my web apps to use classes from my library using Autofac's dependency injection. The Web API app works fine but the Core app doesn't. When I build without installing the Azure Storage NuGet package into the Core app I get the following error:
X.Library' with identity 'X.Library, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' uses 'Microsoft.WindowsAzure.Storage,
Version=8.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
which has a higher version than referenced assembly
'Microsoft.WindowsAzure.Storage' with identity
'Microsoft.WindowsAzure.Storage, Version=8.1.4.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35
Which leads me to believe that ASP.NET Core 2 apps have Azure Storage pre-installed - I can't find any reference to it in the project though! Weird.
So I have tried to fixed this by installing the Azure Storage (v8.7.0) package which matches the version installed in the library I am using into my Core app. The app now builds and my dependencies are injected but when I try to use them I get MissingMethodExceptions for the methods CreateIfNotExists and CreateQuery. While my Web API app can query Azure Table Service my Core app can't use the same methods to do so.
After some research it seems that the ASP.NET Core implementation of the Azure Storage library has removed some synchronous methods and at runtime it uses this version rather than the .NET Framework compatible version my library references.
Is there any way to remove Azure Storage from the ASP.NET Core 2 app? Is it preinstalled, as I suspect?
I guess the easiest way to fix it is to use methods that are present in the Framework and Core implementations, is this how you'd fix it?
I found a solution to this problem with the help of this blog post: https://weblog.west-wind.com/posts/2017/Jun/22/MultiTargeting-and-Porting-a-NET-Library-to-NET-Core-20
The post talks you through the process of porting a .Net Library to a .Net Standard library that targets multiple runtime versions. This turns out to be exactly what I needed to do.
I took my service that I had written in .Net framework 4.5.1 and copied the files to a new .Net Standard library I created. I then changed the target frameworks to support multiple runtime versions manually (you can't do this using the Visual Studio UI at time of writing). For my purposes I used the following to support .Net Core 2, .Net Standard and .Net 4.7.0:
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.0;net47</TargetFrameworks>
</PropertyGroup>
The framework you write first is the one that is targeted but I found that Visual Studio gave me errors for methods that weren't available in all versions of the Azure Storage library so I was able to write a service which worked on all three without writing any runtime-specific code.

Access wcf from netcoreapp2.0

I have a asp dotnet core 2.0 project that needs to talk to a downstream WCF service
The proj file is targeting netcoreapp2.0
I have added nuget packages for System.ServiceModel.Primitives and have almost everything I need apart from something in the System.ServiceModel.Configuration namespace which doesnt appear to be available on Nuget
In the past, I have successfully talked to the WCF service in a netcore1.1 project (by making it target net461)
However, this doesnt appear to be an option if you want to take advantage of netCore2.0 functionality. If you target net461 then you cant access netcore2.0 features
Should this be possible?
Am I doing something wrong?
Can you target net461 and also use netcore2.0 features?
or is there a way I can target netcoreapp2.0 and still access System.ServiceModel.Configuration?
Or do I need to target netcoreapp2.0 and do something else that allows me to access System.ServiceModel.Configuration?
thanks
If you use at least VS 2017 version 15.5, you can add the WCF service as a connected service. The wizard will add the required packages and generate the client code. (in previous VS 2017 versions, you'd need a preview extension).
You can access this wizard from the "Add Connected Service" context menu item: