No redirect to SingleSignOnService location when challenge occurs in Web Forms project - owin

I've taken over a project and some package upgrading was necessary for other things so I went from these where things worked...
<package id="Kentor.AuthServices" version="0.18.0" targetFramework="net452" />
<package id="Kentor.AuthServices.Owin" version="0.18.0" targetFramework="net452" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net452" />
To these...
<package id="Sustainsys.Saml2" version="2.2.0" targetFramework="net472" />
<package id="Sustainsys.Saml2.Owin" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Owin" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security" version="4.0.0" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Cookies" version="4.0.0" targetFramework="net472" />
I followed the migration guide but fail to get a redirect to the SingleSignOnService location when a challenge occurs in my Web Forms project.
My Web.config has the following structure...
<sustainsys.saml2 entityId="https://demo.local/AuthServices"
returnUrl="https://demo.local"
publicOrigin="https://demo.local"
modulePath="/AuthServices">
<serviceCertificates>
<add fileName="~/somename.pfx"
use="Signing" />
</serviceCertificates>
<identityProviders>
<add entityId="My-IDP"
allowUnsolicitedAuthnResponse="true"
loadMetadata="true"
metadataLocation="https://some-saml2-idp.com/metadata" />
</identityProviders>
</sustainsys.saml2>
And my Owin startup...
var defaultSignInAsAuthType = "Cookies";
app.SetDefaultSignInAsAuthenticationType(defaultSignInAsAuthType);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = defaultSignInAsAuthType,
ReturnUrlParameter = "returnUrl",
LoginPath = new PathString("/login"),
LogoutPath = new PathString("/logout")
});
var saml2Options = new Saml2AuthenticationOptions(true);
app.UseSaml2Authentication(saml2Options);
app.UseStageMarker(PipelineStage.Authenticate);
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Name;
I've tried triggering a challenge in a path mapping...
ctx.Authentication.Challenge(new AuthenticationProperties()
{
RedirectUri = "https://demo.local"
});
My questions are if I upgraded the Owin packages too far and if someone has some troubleshooting hints?

The default setting for active/passive has changed. Previously the middleware was active by default, which meant it listened to any Challenge call. Now it is passive, so you have to use the Challenge overload that specifies an authentication scheme and set it to "Saml2".
The reason for the change is to better follow best practice for how middleware for external authentication should behave.

Related

"Not available: couldn't connect to your application" live metrics Azure Application Insights

I have web application in .Net Framework 4.7.2. It deployed as App service in Azure. I have enable Application Insights in it. And I can read logs. But when I click on "Live metrics", It shows "Not available: couldn't connect to your application"
I have added latest packages of "Microsoft.ApplicationInsights" in application. Also in azure portal, in that app service, app settings "APPINSIGHTS_INSTRUMENTATIONKEY", "APPLICATIONINSIGHTS_CONNECTION_STRING" added in configuration.
Also I check Microsoft troubleshoot article "Troubleshoot couldn't connect to your application" but steps which mention in that article are already followed.
I am not able to find reason why it could not connect to application. Can someone help me regarding this?
When you create the App Service in the Azure Portal, it will also create the App Insights Resource as well:
You have to connect the Web Application to the associated App Insights Resource before publishing the Web Site:
When you run the Web Application (Open the URL), then the Request Rate, Time will be shown in the Live Metrics. As you can see in below Gifs it is showing the Request Rate, Time when I refresh the home page:
Note:
Check you have the packages related to Application Insights in Web.Config File > Under Configuration Section:
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2" />
<httpModules>
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="TelemetryCorrelationHttpModule" />
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="managedHandler" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
</system.webServer>
Packages.config file code:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.ApplicationInsights" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.Web" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.22.0-beta1" targetFramework="net472" />
<package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.8" targetFramework="net472" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="4.1.0-preview1" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="7.0.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="7.0.0-preview.2.22152.2" targetFramework="net472" />
</packages>
Refer to this MS Doc for more information.

My Website is working properly in local server But when publish it on azure and run then it give me this error

My Website is working properly in local server But when publish it on azure and run then it give me this error of
Could not load file or assembly 'Microsoft.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net472" />
<package id="bootstrap" version="3.4.1" targetFramework="net472" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net472" />
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net472" />
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
<package id="Microsoft.Azure.Amqp" version="2.4.2" targetFramework="net472" />
<package id="Microsoft.Azure.Devices" version="1.4.1" targetFramework="net472" />
<package id="Microsoft.Azure.Devices.Shared" version="1.16.0" targetFramework="net472" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.Azure.Services.AppAuthentication" version="1.0.3" targetFramework="net472" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.14.2" targetFramework="net472" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.11" targetFramework="net472" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net472" />
<package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net472" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.20" targetFramework="net472" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net472" />
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net472" />
<package id="Owin" version="1.0" targetFramework="net472" />
<package id="PCLCrypto" version="2.0.147" targetFramework="net472" />
<package id="PInvoke.BCrypt" version="0.3.2" targetFramework="net472" />
<package id="PInvoke.Kernel32" version="0.3.2" targetFramework="net472" />
<package id="PInvoke.NCrypt" version="0.3.2" targetFramework="net472" />
<package id="PInvoke.Windows.Core" version="0.3.2" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="4.0.4.403061554" targetFramework="net472" />
<package id="System.IO" version="4.1.0" targetFramework="net472" />
<package id="System.Net.WebSockets" version="4.0.0" targetFramework="net472" />
<package id="System.Net.WebSockets.Client" version="4.0.2" targetFramework="net472" />
<package id="System.Runtime" version="4.1.0" targetFramework="net472" />
<package id="System.Runtime.Serialization.Primitives" version="4.1.1" targetFramework="net472" />
<package id="System.Security.Cryptography.Algorithms" version="4.2.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Encoding" version="4.0.0" targetFramework="net472" />
<package id="System.Security.Cryptography.Primitives" version="4.0.0" targetFramework="net472" />
<package id="System.Security.Cryptography.X509Certificates" version="4.1.0" targetFramework="net472" />
<package id="Validation" version="2.2.8" targetFramework="net472" />
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
<package id="WindowsAzure.ServiceBus" version="6.0.0" targetFramework="net472" />
<package id="WindowsAzure.Storage" version="9.1.1" targetFramework="net472" />
</packages>
As i can see in your packages.config, Microsoft.owin version is
**<package id="Microsoft.Owin" version="3.0.1" targetFramework="net472" />**
And your application is Errorin out **Could not load file or assembly 'Microsoft.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'**
Please try to add dependent assembly tag in your web.config like below
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
See if it works, Also if you are using 4.0.0 version in your project then consider updating the reference in your packages.config as well.
Hope it helps.

How to configure OWIN Web API 1 via IAppBuilder

TL;DR: How do I configure OWIN Web API 1 via a StartUp class or alternatively use the HttpSelfHostServer with the static files extension?
I have a working self-hosted OWIN Web API 2 project, which I'd like to downgrade to .Net 4.0 - I'd prefer not to install the .Net 4.5+ framework replacement, because of unknown side-effects on a production machine.
I can't use Microsoft.AspNet.WebApi.OwinSelfHost because it's not available for .Net 4.0 and therefore I can't call the IAppBuilder.useWebApi() extension method for registering my configuration.
I'm bootstraping the server now like this: WebApp.Start(Of StartUp)(url:="...")
and the StartUp class looks like this, but I can't set the config:
Public Class StartUp
Public Sub Configuration(app As IAppBuilder)
' the host should be obsolete, as it's already configured in the app context
Dim config As New HttpSelfHostConfiguration("http://localhost:9000")
' config.MapHttpAttributeRoutes()
config.Routes.MapHttpRoute(
name:="DefaultApi",
routeTemplate:="api/{controller}/{id}",
defaults:=New With {.id = RouteParameter.Optional}
)
' configure formatters, converters, filters ...
' app.UseWebApi(config)
Dim physicalFileSystem As New PhysicalFileSystem("...\static")
app.UseDefaultFiles(New DefaultFilesOptions With {.FileSystem = physicalFileSystem})
app.UseStaticFiles(New StaticFileOptions With {.FileSystem = physicalFileSystem, .ServeUnknownFileTypes = True})
End Sub
End Class
If I'd use the documented Web API 1 approach of bootstrapping the server (see below), I don't know how to configure the static files extension:
var config = new HttpSelfHostConfiguration("http://localhost:8080");
config.Routes.MapHttpRoute(
"API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
using (HttpSelfHostServer server = new HttpSelfHostServer(config)) {
server.OpenAsync().Wait();
Console.WriteLine("Press Enter to quit.");
Console.ReadLine();
}
Although I've checked the AspNetWebStack sources, I think the message handling has changed between V2.1.0 and V5.0.0+ and therefore I can't apply that approach.
I'm using the following nuget packages - which I might reduce after its working:
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="4.0.30506.0" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.0.20710.0" targetFramework="net40" />
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Diagnostics" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.FileSystems" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Host.HttpListener" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.SelfHost" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.StaticFiles" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>
Btw. although I've used VB.Net in the example, feel free to use your preferred language in your answer.

Azure WebJobs NuGet Package Error

I would like to know if someone has experienced running error on Azure WebJobs Queue sample on Visual Studio templates.
The sample running to issue after I updated all the packages on NuGet manager.
This is the error message:
System.InvalidOperationException
HResult=0x80131509
Message=Microsoft.WindowsAzure.Storage is deployed incorrectly. Are you missing a Table Service assembly (Microsoft.Data.Services.Client, Microsoft.Data.OData or Microsoft.Data.Edm) or a related binding redirect?
Source=Microsoft.Azure.WebJobs.Host
StackTrace:
at Microsoft.Azure.WebJobs.Host.AzureStorageDeploymentValidator.Validate()
at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.CreateStaticServices(JobHostConfiguration config)
at Microsoft.Azure.WebJobs.JobHost.InitializeServices()
at Microsoft.Azure.WebJobs.JobHost.<InitializeHostAsync>d__44.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.JobHost.<StartAsyncCore>d__25.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.JobHost.Start()
at Microsoft.Azure.WebJobs.JobHost.RunAndBlock()
at QueueSample.Program.Main() in C:\Users\adity\Documents\Visual Studio 2017\Projects\AzureQueueStorage\QueueSample\Program.cs:line 28
Inner Exception 1:
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Table.DataServices.TableServiceContext' from assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
This is the list of installed packages:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="2.0.4" targetFramework="net461" />
<package id="Microsoft.Azure.WebJobs" version="2.1.0" targetFramework="net461" />
<package id="Microsoft.Azure.WebJobs.Core" version="2.1.0" targetFramework="net461" />
<package id="Microsoft.Data.Edm" version="5.8.3" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.3" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.8.3" targetFramework="net461" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.0" targetFramework="net461" />
<package id="Microsoft.NETCore.Platforms" version="2.0.1" targetFramework="net461" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net461" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.3" targetFramework="net461" />
<package id="NETStandard.Library" version="2.0.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net461" />
<package id="System.Console" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net461" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net461" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization" version="4.3.0" targetFramework="net461" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net461" />
<package id="System.IO" version="4.3.0" targetFramework="net461" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net461" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Linq" version="4.3.0" targetFramework="net461" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Http" version="4.3.3" targetFramework="net461" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net461" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net461" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net461" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net461" />
<package id="System.Spatial" version="5.8.3" targetFramework="net461" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net461" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net461" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net461" />
<package id="System.Threading" version="4.3.0" targetFramework="net461" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net461" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net461" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="9.1.0" targetFramework="net461" />
</packages>
When I using default templates and packages, it is running without error.
After I have updated the NuGet packages, it is running error like above.
Thank You
Message=Microsoft.WindowsAzure.Storage is deployed incorrectly
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Table.DataServices.TableServiceContext' from assembly 'Microsoft.WindowsAzure.Storage, Version=9.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
According to your error message, I suppose the issue may be related with the compatibility.
TableServiceContext has been deprecated since version 4.0 and was removed in version 9.0 as part of dropping OData dependencies. You'd better use the compatible version for packages(such as WindowsAzure.Storage 8.7.0). For more details about this issue, you could read this article.
My problem was that I had an outdated nuget package. I tried to uninstall the nuget package, found it's dependency and from this I upgraded
Microsoft.Azure.WebJobs, Version=2.0.0.0
to
Microsoft.Azure.WebJobs, Version=2.2.0.0

TypeLoadException with DocumentClient on Visual Studio Mac

I downloaded the getting started sample app from Azure Cosmos DB and am getting the following error with Visual Studio Mac
System.TypeLoadException: Could not resolve type with token 010000f6 (from typeref, class/assembly System.Diagnostics.Eventing.EventProviderTraceListener, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
at Microsoft.Azure.Documents.Client.DocumentClient.Initialize (System.Uri serviceEndpoint, Microsoft.Azure.Documents.Client.ConnectionPolicy connectionPolicy, System.Nullable`1[T] desiredConsistencyLevel) [0x00014] in <f7f11c3ada88490092c73d6bef54be97>:0
at Microsoft.Azure.Documents.Client.DocumentClient..ctor (System.Uri serviceEndpoint, System.String authKeyOrResourceToken, Microsoft.Azure.Documents.Client.ConnectionPolicy connectionPolicy, System.Nullable`1[T] desiredConsistencyLevel) [0x00069] in <f7f11c3ada88490092c73d6bef54be97>:0
at GraphGetStarted.Program.Main (System.String[] args) [0x00021] in /DocumentDB-Quickstart-DotNet-Graph/GraphGetStarted/Program.cs:29
And the code where it fails
DocumentClient client = new DocumentClient(url, authKey, policy);
Here's the packages.config: do I need to set a different targetFramework for Visual Studio Mac?
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.DocumentDB" version="1.14.0" targetFramework="net452" />
<package id="Microsoft.Azure.Graphs" version="0.2.0-preview" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.Common" version="1.3.0" targetFramework="net452" />
<package id="Microsoft.CodeAnalysis.CSharp" version="1.3.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net452" />
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
<package id="System.Collections.Immutable" version="1.1.37" targetFramework="net452" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net452" />
<package id="System.Globalization" version="4.3.0" targetFramework="net452" />
<package id="System.Linq" version="4.3.0" targetFramework="net452" />
<package id="System.Reflection.Metadata" version="1.2.0" targetFramework="net452" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime" version="4.3.0" targetFramework="net452" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net452" />
<package id="System.Threading" version="4.3.0" targetFramework="net452" />
</packages>
I think Protocol.Tcp is not is .NET Core. Can you try using
new ConnectionPolicy { ConnectionMode = ConnectionMode.Gateway, ConnectionProtocol = Protocol.Https }))
or
new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Https }))
Thanks!
According to your comment, you use .net project. Please don't try to run .net project on the MacOS. We can create .NET Core apps that run on Windows, Linux and macOS. We also could get info about azure DocumentDB and .NET Core from the official tutorials.

Resources