Today, I've created an Azure Function to connect to Office365.
This is the code, which it works on my PC:
#Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
#Import-Module AzureAD -UseWindowsPowershell
Import-Module MSonline -UseWindowsPowershell -Force
$PWord = ConvertTo-SecureString –String "MyPass" –AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList "MyTenantAdmin", $PWord
#Connect-AzureAD -credential $Credential
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Connect-MSolService -credential $Credential
However, when I try it on the Azure Function, I obtain this error:
2022-12-28T20:45:09Z [Error] ERROR: Authentication Error: Unable
to complete authentication request (potentially a proxy issue)
OriginInfo : localhost Exception :
Type : System.Management.Automation.RemoteException
SerializedRemoteException : System.Exception: Authentication Error: Unable to complete authentication request (potentially a proxy
issue) --->
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException: User
realm discovery failed
at Microsoft.Identity.Core.WsTrust.CommonNonInteractiveHandler.d__5.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Core\WsTrust\CommonNonInteractiveHandler.cs:line
74
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquireTokenUsernamePasswordHandler.d__5.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Internal\Flows\NonInteractive\AcquireTokenUsernamePasswordHandler.cs:line
77
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquireTokenHandlerBase.d__60.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Internal\Flows\AcquireTokenHandlerBase.cs:line
241
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.d__39.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\AuthenticationContext.cs:line
542
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.d__0.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Features\WinCommon\AuthenticationContextIntegratedAuthExtensions.cs:line
59
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.Online.Administration.Automation.CommonFiles.AuthManager.AuthenticateUser(AuthenticationContext
ac, PSCredential cred) in
X:\bt\1225946\repo\src\dev\PowerShell.V1\modules\psmodule\CommonFiles\AuthManager.cs:line
115
--- End of inner exception stack trace ---
at Microsoft.Online.Administration.Automation.CommonFiles.AuthManager.ProcessADALException(AdalException
aeGeneral, AuthenticationContext ac, IDictionary`2 accessTokens) in
X:\bt\1225946\repo\src\dev\PowerShell.V1\modules\psmodule\CommonFiles\AuthManager.cs:line
529
at Microsoft.Online.Administration.Automation.CommonFiles.AuthManager.AuthenticateUser(AuthenticationContext
ac, PSCredential cred) in
X:\bt\1225946\repo\src\dev\PowerShell.V1\modules\psmodule\CommonFiles\AuthManager.cs:line
136
at Microsoft.Online.Administration.Automation.ConnectMsolService.MsolCmdletProcessRecord()
in
X:\bt\1225946\repo\src\dev\PowerShell.V1\modules\psmodule\Cmdlets\Connect-Service.cs:line
247
SerializedRemoteInvocationInfo : System.Management.Automation.InvocationInfo
ErrorRecord :
Exception :
Type : System.Management.Automation.RemoteException
SerializedRemoteException : System.Exception: Authentication Error: Unable to complete authentication request
(potentially a proxy issue) --->
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException: User
realm discovery failed
at Microsoft.Identity.Core.WsTrust.CommonNonInteractiveHandler.d__5.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Core\WsTrust\CommonNonInteractiveHandler.cs:line
74
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquireTokenUsernamePasswordHandler.d__5.MoveNext()
in
D:\a\1\s\src\Microsoft.IdentityModel.Clients.ActiveDirectory\Internal\Flows\NonInteractive\AcquireTokenUsernamePasswordHandler.cs:line
77
--- End of stack trace from previous location where exception was thrown ---
The user has not MFA enabled.
Enable "System assigned identity" under Identity in Function App to register with AzureAD when running insideAzure functions. It will then grant all permissions/scopes required to operate with AzureAD-related modules.
To run connect-MsolService, MsOnline(Connecting to 365) module needs to be added in requirements.psd1 under App files in Azure functions. comes under Azure Acitve directory Module.
check the version compatibility for Msonline & Powershell
Add 64 bit version installer to handle binaries for the online office 365 modules.
FunctionApp -> Settings -> Configuration:
After checking all the above conditions try executing the same script to connect Msolservice.
Other approach:
As detailed in the article, I created a triggered function and connected to MsolService (office 365) with FTP hostname.
Function Properities in Portal:
Install Msoline module in local folder and deploy it to azure. Add username & password credentials in local path and mention that path in script to get the encrypted values.
FunctionApp -> Configuration -> Application settings:
Script:
param($Request, $TriggerMetadata)
$ModuleName = 'MSOnline'
$ModuleVersion = '1.1.*'
$user = $Env:user
$pword = $Env:pword
$path = "C:xxxx"
Import-module $ModuleName
$pWord = ConvertTo-SecureString –String $pword –AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $user, $pWord
Connect-MsolService -Credential $credential
Got successful response as shown:
Monitor Log check:
Related
So, I am using method number 2 here:
https://www.vrdmn.com/2019/01/working-with-application-permissions.html
My code is as follows:
string siteUrl = "https://xx.sharepoint.com/sites/test212/";
string siteUrl2 = "https://xx.sharepoint.com/sites/test2122/";
//Client id and Client secret created through appregnew.aspx and permissions granted through appinv.aspx
var authManager = new OfficeDevPnP.Core.AuthenticationManager();
//PnP Core method
ClientContext clientContext = authManager.GetAppOnlyAuthenticatedContext(siteUrl, "xx", "xx");
var teamNoGroupSiteResult = await clientContext.CreateSiteAsync(new OfficeDevPnP.Core.Sites.TeamNoGroupSiteCollectionCreationInformation()
{
Url = siteUrl,
Title = "Team no group Site Test",
Description = "Site description",
Lcid = 1033
});
var communicationSiteResult = await clientContext.CreateSiteAsync(new OfficeDevPnP.Core.Sites.CommunicationSiteCollectionCreationInformation()
{
Url = siteUrl2,
Title = "Modern no group Site Test",
Description = "Site description",
Lcid
});
SO, I created the app only registration in my tenant, then I tried this code and it says I am unauthorized.
The error I get is:
{
"Message": "An error has occurred.",
"ExceptionMessage": "Token request failed.",
"ExceptionType": "Microsoft.IdentityModel.SecurityTokenService.RequestFailedException",
"StackTrace": " at SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)\r\n at OfficeDevPnP.Core.Utilities.TokenHelper.GetAppOnlyAccessToken(String targetPrincipalName, String targetHost, String targetRealm)\r\n at OfficeDevPnP.Core.AuthenticationManager.EnsureToken(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix)\r\n at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String realm, String appId, String appSecret, String acsHostUrl, String globalEndPointPrefix)\r\n at OfficeDevPnP.Core.AuthenticationManager.GetAppOnlyAuthenticatedContext(String siteUrl, String appId, String appSecret)\r\n at LuloWebApi.Controllers.TenantController.<Test>d__1.MoveNext() in C:\\Users\\levalencia30\\Source\\Repos\\LuloBackend\\TenantManagementWebApi\\Controllers\\TenantController.cs:line 42\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "The remote server returned an error: (401) Unauthorized.",
"ExceptionType": "System.Net.WebException",
"StackTrace": " at System.Net.HttpWebRequest.GetResponse()\r\n at SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2WebRequest.GetResponse()\r\n at SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)"
}
}
According to this issue it isn't possible using PnP as of yet. There is code change to address it in the Dev branch though so you could copy it and create your own CreateSiteAsync extension method and copy the sitecollection.cs into your own project.
Failing that you could call the Rest API yourself based on the code in the relevant CreateAsync method.
Edit: I could never get app only with a ClientId and secret to work. Try ClientId and Cert method outlined here
You cant do that PnP. You can try a code that changes it in the dev branch. This would allow you to copy it and make a CreateSiteAsync extension method and simply copy sitecollction.cs to your project.
I have already created the server and I am using the following code:
New-AzureRmSqlElasticPool -ResourceGroupName $resourcegroupname -ServerName $servername -ElasticPoolName "ElasticPool071" -VCore 1 -Edition "GeneralPurpose" -ComputeGeneration "Gen5" -InformationVariable ee -debug -ErrorVariable ErrorMessages
the ouput I am recieving is>>
Set-AzureRmSqlElasticPool : An unexpected error occured while processing the request. Tracking ID: 'a2936090-e7af-4203-be1c-9425932055f3'
At line:1 char:2
+ Set-AzureRmSqlElasticPool -ResourceGroupName $resourcegroupname -Se ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmSqlElasticPool], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ElasticPool.Cmdlet.SetAzureSqlElasticPool
DEBUG: AzureQoSEvent: CommandName - Set-AzureRmSqlElasticPool; IsSuccess - False; Duration - 00:00:26.8490006; Exception - Microsoft.Rest.Azure.CloudException: An unexpected error occured while processing the request. Tracking ID: 'a2936090-e7af-
4203-be1c-9425932055f3'
at Microsoft.Azure.Management.Sql.ElasticPoolsOperations.<BeginUpdateWithHttpMessagesAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.Sql.ElasticPoolsOperations.<UpdateWithHttpMessagesAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.Sql.ElasticPoolsOperationsExtensions.<UpdateAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.Sql.ElasticPoolsOperationsExtensions.Update(IElasticPoolsOperations operations, String resourceGroupName, String serverName, String elasticPoolName, ElasticPoolUpdate parameters)
at Microsoft.Azure.Commands.Sql.ElasticPool.Services.AzureSqlElasticPoolAdapter.UpsertElasticPool(AzureSqlElasticPoolModel model)
at Microsoft.Azure.Commands.Sql.ElasticPool.Cmdlet.SetAzureSqlElasticPool.PersistChanges(IEnumerable`1 entity)
at Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase`2.<>c__DisplayClass16_0.<ExecuteCmdlet>b__0()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ConfirmAction(String processMessage, String target, Action action)
at Microsoft.Azure.Commands.Sql.Common.AzureSqlCmdletBase`2.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
Could you please help!?
For Gen 5 Compute Generation, you must allocate a minimum of 2 vCores. For Gen 4 you can allocate 1 vCore.
Azure SQL Database vCore-based purchasing model limits for elastic pools
SQL Database pricing options
I am using EventProcessorHost in webjob with multiple instances - giving exception Microsoft.ServiceBus.Messaging.LeaseLostException. Perticularly only one instance is giving this exception.
It is not giving any exception when I am running it as single instances
Microsoft.ServiceBus.Messaging.LeaseLostException: Exception of type 'Microsoft.ServiceBus.Messaging.LeaseLostException' was thrown. ---> Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (409) Conflict. ---> System.Net.WebException: The remote server returned an error: (409) Conflict.
at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase1 cmd, Exception ex) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Shared\Protocol\HttpResponseParsers.Common.cs:line 50
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.<>c__DisplayClass33.<RenewLeaseImpl>b__32(RESTCommand1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 3186
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 299
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 50
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.EndRenewLease(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 1982
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.b__3(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 114
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__23.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RoutingServiceWebJob.DataProcessorFactory.EventHubDataProcessor.d__37.MoveNext() in d:\a\1\s\RoutingServiceWebJob\DataProcessorFactory\EventHubDataProcessor.cs:line 163
I am reading messages one at a time. Please suggest.
I was able to avoid this by setting the Host name to be a unique string. For example
var eventProcessorHostName = Guid.NewGuid().ToString();
I got an exception of Microsoft.ServiceBus.Messaging.LeaseLostException, in my EventHub processor.
what does this exception mean? What is the possible root cause of this exception?
Following are stack track:
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__24.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__25.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at MyEventHub.EventProcessor`1.d__6.MoveNext()\r\n\r\nMicrosoft.WindowsAzure.Storage.StorageException : \"The remote server returned an error: (409) Conflict.\":
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 60\r\n
at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.b__3(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:line 115\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.ServiceBus.Messaging.BlobLeaseManager.d__24.MoveNext()\r\n\r\nSystem.Net.WebException : \"The remote server returned an error: (409) Conflict.\":
at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase1 cmd, Exception ex) in c:\\Program Files (x86)\\Jenkins\\workspace\\release_dotnet_master\\Lib\\Common\\Shared\\Protocol\\HttpResponseParsers.Common.cs:line 50\r\n
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.<>c__DisplayClass33.<RenewLeaseImpl>b__32(RESTCommand1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 3186\r\n
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 306"
And the only internal exception in my own code is:
at MyEventHub.EventProcessor`1.<< CloseAsync >> d__6.MoveNext()\r\n\r\nMicrosoft.WindowsAzure.Storage.StorageException : \"The remote server returned an error: (409) Conflict.\":
...
And here is the code of CloseAsync:
public async Task CloseAsync(PartitionContext context, CloseReason reason)
{
try
{
if (reason == CloseReason.Shutdown)
{
await context.CheckpointAsync();
}
}
catch (Exception ex)
{
this.HandleException(ex);
}
finally
{
this.configuration.DecrementOpenedPartitionCount?.Invoke();
}
}
MyEventHub is hosted in worker role which deployed 2 instance in Azure.
#Youxu , for your EventHub, how many receivers ( EventProcessorHost ) are configured?. As per my knowledge we can have only one active receiver with certain epoch. If we create a EventHub listener ( with default options) while one listener is already listing to a EventHub, newly created listener gets higher epoch and first listener gets disconnected due to LeaseLostException
Check if you are (accidentally) running more than one receiver for same EventHub concurrently.
I have an IdentityServer3 server setup and it's configured to use Entity Framework for getting client and scope information from the database.
When I add a new scope to the database (dbo.Scopes) if ShowInDiscoveryDocument = 0 then all is well and the well-known document loads correctly. However, if ShowInDiscoveryDocument = 1 then I get the following error:
Message: "An error has occurred.",
ExceptionMessage: "The type initializer for 'IdentityServer3.EntityFramework.Entities.EntitiesMap' threw an exception.",
ExceptionType: "System.TypeInitializationException",
StackTrace: " at IdentityServer3.EntityFramework.Entities.EntitiesMap.ToModel(Scope s) at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext() at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) at IdentityServer3.Core.Endpoints.DiscoveryEndpointController.d__11.MoveNext() in
c:\local\identity\server3\IdentityServer3\source\Core\Endpoints\Connect\DiscoveryEndpointController.cs:line 89 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.System.Web.Http908956.TaskHelpersExtensions.d__3`1.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Validation\ScopeValidator.cs:line 0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Validation\ScopeValidator.cs:line 0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Validation\ScopeValidator.cs:line 0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext() in c:\local\identity\server3\IdentityServer3\source\Core\Validation\ScopeValidator.cs:line 0",
InnerException: {
Message: "An error has occurred.",
ExceptionMessage: "Could not load type 'AutoMapper.IMapperConfiguration' from assembly 'AutoMapper, Version=5.0.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005'.",
ExceptionType: "System.TypeLoadException",
StackTrace: " at IdentityServer3.EntityFramework.Entities.EntitiesMap..cctor()"
this problem has been reported and I think fixed in the sources, I do not know if the nugget package has the fix yet.