GithubHelp home page GithubHelp logo

bdebaere / unofficial.microsoft.analysisservices.adomdclientnetcore Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 13.0 342 KB

Unofficial AdomdClient ported to .NET Core. WARNING: may not support your scenario, use at your own risk! WARNING: does not support WindowsPrincipal.

License: MIT License

C# 100.00%

unofficial.microsoft.analysisservices.adomdclientnetcore's People

Contributors

bdebaere avatar twenzel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unofficial.microsoft.analysisservices.adomdclientnetcore's Issues

Columns not properly typed

When using AdomdDataReader.GetValue(int), all the values are strings instead of being properly typed to the type returned in the xml.
After doing some analysis, I found a commented row in XmlaDataReader, row 1021 which explains my problem.
Uncommenting the row and commenting row 1022 fixes our issue, because the default value would be null so the test just after gets properly the field type.
The current code returns object by default, so it never tries to get the proper type.

Is there a good reason for using this row instead of the commented one ?

.net core + nuget package: Could not load file or assembly 'System.Configuration.ConfigurationManager

Scenario:

  • Create new .net core application
  • Add reference Unofficial.Microsoft.AnalysisServices.AdomdClient nuget package, version 13.0.4001 (latest atm)
  • Try to open a connection to an SSAS instance

var connectionString = "Provider = MSOLAP.7; Data Source = hidden Catalog=hidden;User ID=hidden Password=hidden Properties="hidden";Application Name='hidden';";
using (var connection = new AdomdConnection(connectionString))
{
connection.Open();
}

Exception thrown: 'System.IO.FileNotFoundException' in Microsoft.AnalysisServices.AdomdClient.dll
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.AnalysisServices.AdomdClient.dll
Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

Unable to find resources

Hi i'm testing your lib (version 15.3.1.1) and facing the same excetion as #7

but in my case i'm pretty sure the connection string is correct and i receive a token whick seems ok according to jwt.io

here is the complete exception :
System.Private.CoreLib: Exception while executing function: process. System.Private.CoreLib: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.AnalysisServices.AdomdClient.XmlaSR.resources" was correctly embedded or linked into assembly "AdomdClientNetCore" at compile time, or that all the satellite assemblies required are loadable and fully signed

Any suggestion would be appreciated.

Can you please sign it

I am getting a warning: CSC: Referenced assembly 'AdomdClientNetCore, Version=15.3.1.2, Culture=neutral, PublicKeyToken=null' does not have a strong name.

Exception thrown while opening connection

Following this guide. This issue does not occur in version 15.3.1.

Version: 15.3.1.1

Error message: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.AnalysisServices.AdomdClient.XmlaSR.resources" was correctly embedded or linked into assembly "AdomdClientNetCore" at compile time, or that all the satellite assemblies required are loadable and fully signed.

Stacktrace:

   at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at Microsoft.AnalysisServices.AdomdClient.XmlaSR.Keys.GetString(String key, Object arg0, Object arg1)
   at Microsoft.AnalysisServices.AdomdClient.XmlaSR.HttpStream_ASAzure_TechnicalDetailsText(String rootActivityId, String currentUtcDate)
   at Microsoft.AnalysisServices.AdomdClient.ASAzureUtility.GetExtendedErrorInfo(HttpWebResponse httpResponse)
   at Microsoft.AnalysisServices.AdomdClient.HttpStream.GetExtendedErrorInfo()
   at Microsoft.AnalysisServices.AdomdClient.CompressedStream.GetExtendedErrorInfo()
   at Microsoft.AnalysisServices.AdomdClient.XmlaReader.GetExtendedErrorInfo()
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.ReadXmlaError(XmlReader reader)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.ReadFaultBody(XmlReader reader, XmlaMessageCollection xmlaMessages)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.CheckForSoapFault(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.CheckForError(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Discover(String requestType, String requestNamespace, ListDictionary properties, IDictionary restrictions, Boolean sendNamespacesCompatibility, IDictionary requestProperties)
   at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Discover(String requestType, ListDictionary properties, IDictionary restrictions, Boolean sendNamespacesCompatibility)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.Discover(String requestType, IDictionary restrictions, InlineErrorHandlingType inlineErrorHandling, Boolean sendNamespaceCompatibility)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ReadDataSourceInfo()
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
   at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
   at NzBrokersWebPortal.DataAccess.ReportRepository.GetDataFromAzureAnalysisServices() in C:\Users\mastan\Documents\Git\nzbrokers-web-portal\NzBrokersWebPortal\DataAccess\ReportRepository.cs:line 190

Code:

private async Task GetDataFromAzureAnalysisServices()
		{
			//Grab the token
			//Get servername from Azure Analysis Service (Overview) resource 
			//Format: asazure://<region>.asazure.windows.net/<servername>
			string serverDomain = "australiasoutheast.asazure.windows.net";
			string databaseModel = "nzbrokersdevpilotv1";
			string serverName = $"asazure://{serverDomain}/{databaseModel}";
			string token = await GetAccessToken($"https://{serverDomain}");
			var connectionString = $"Provider=MSOLAP;Data Source={serverName};Initial Catalog={databaseModel};User ID=;Password={token};Persist Security Info=True;Impersonation Level=Impersonate";

			try
			{
				//read data from AAS
				using (AdomdConnection connection = new AdomdConnection(connectionString))
				{
					connection.Open();
					var mdX = @"EVALUATE (
					  TOPN (
						10,
						SUMMARIZECOLUMNS (
						  'Customer'[First Name],
						  'Customer'[Last Name]
						),
						'Customer'[Last Name],1
					  )
					)";

					using (AdomdCommand command = new AdomdCommand(mdX, connection))
					{
						var results = command.ExecuteReader();
						foreach (var result in results)
						{
							Console.WriteLine($"FirstName: {result[0]?.ToString()}; LastName: {result[1]?.ToString()}");
						}
					}
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex);
			}
		}

		private static async Task<string> GetAccessToken(string aasUrl)
		{
			var tenantId = "redacted";					// TODO: Move this into userSecrets
			var appId = "redacted";						// TODO: Move this into userSecrets
			var appSecret = "redacted";			// TODO: Move this into userSecrets
			string authorityUrl = $"https://login.microsoftonline.com/{tenantId}";

			var authContext = new AuthenticationContext(authorityUrl);

			// Config for OAuth client credentials 
			var clientCred = new ClientCredential(appId, appSecret);
			AuthenticationResult authenticationResult = await authContext.AcquireTokenAsync(aasUrl, clientCred);

			//get access token
			return authenticationResult.AccessToken;
		}

Closing AdomdConnection throws a 'operation was canceled' error

When a AdomdConnection is closed, an exception is thrown.
Exception: "System.OperationCanceledException: 'The operation was canceled.'"

This happens both when calling the close method of the AdomdConnection class and when getting out of a using(AdomdConnection) block.

ExecuteCellSet bug

Hi! Thanks for the library! I found that ExecuteCellSet() throws an exception due to wrong code in MDDatasetFormatter.ReadCellInfo() method. There is commented out line "goto IL_136;", it should be restored (and label moved out from the try block), then it works.

An unhandled exception of type 'System.NullReferenceException' occurred in AdomdClientNetCore.dll: 'Object reference not set to an instance of an object.'

An unhandled exception of type 'System.NullReferenceException' occurred in AdomdClientNetCore.dll: 'Object reference not set to an instance of an object.'
at Microsoft.AnalysisServices.AdomdClient.StreamInteropHelper.ProcessRequest(XASC comClass, Stream requestStream)
at Microsoft.AnalysisServices.AdomdClient.IXMLAStream.WriteEndOfMessage()
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.WriteEndOfMessage(Boolean callBaseDirect)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.EndRequest(Boolean useBinaryXml)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.CreateSession(ListDictionary properties, Boolean sendNamespaceCompatibility, String sessionToken)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.CreateSession(Boolean sendNamespaceCompatibility)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToIXMLA(Boolean createSession)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
at TestBed.Program.GetDataFromAzureAnalysisService(String query, String databasename) in xxxxx\Program.cs:line 34
at TestBed.Program.Main(String[] args) in xxxxxxxx\Program.cs:line 14

Error opening connection: 'String reference not set to an instance of a String'

I'm getting this exception when i try to open up the connection in .net core console application (.NET Core 2.1 on VS2017 Community - v15.8.9) .

Environment:

  • Visual Studio Community 2017 (version 15.8.9)
  • Windows Server 2012 R2 Standard

Exception

System.ArgumentNullException: 'String reference not set to an instance of a String.'

Stack Trace:
at System.Reflection.RuntimeAssembly.GetResource(RuntimeAssembly assembly, String resourceName, UInt64& length, StackCrawlMarkHandle stackMark, Boolean skipSecurityCheck)
at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name, StackCrawlMark& stackMark, Boolean skipSecurityCheck)
at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name)
at Microsoft.AnalysisServices.AdomdClient.AadAuthParams.GetResourceAsStream(String resourceName)
at Microsoft.AnalysisServices.AdomdClient.AadAuthParams.ReadLocalSecurityAuthParams()
at Microsoft.AnalysisServices.AdomdClient.AadAuthParams.get_LocalSecurityAuthParams()
at Microsoft.AnalysisServices.AdomdClient.AadAuthParams.FindMatchingAuthParams(String identityProvider, Uri dataSourceUri)
at Microsoft.AnalysisServices.AdomdClient.AadAuthenticator.AcquireToken(Uri dataSourceUri, String dataSource, String identityProvider, String userId, String password, Boolean useAdalCache)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenHttpConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.OpenConnection(ConnectionInfo connectionInfo, Boolean& isSessionTokenNeeded)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect(Boolean toIXMLA)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
at ConsoleApp1.Program.Main(String[] args) in C:\Users<username>\Source\Repos\ConsoleApp1\ConsoleApp1\Program.cs:line 15

Here is the source code:
//Accessing Analysis service hosted in Azure using connection string string connectionString = "Provider=MSOLAP;Data Source=asazure://westeurope.asazure.windows.net/<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>" using(AdomdConnection connection = new AdomdConnection(connectionString)) { connection.Open(); }

I did try it with query as well but the same error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.