You are receiving the following error message when trying to publish a SharePoint 2013 Workflow:
Microsoft.SharePoint.SPException: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator.
at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version)
at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvide
Former, if you are trying to activate the Site Feature “Workflows can use app permissions” you are confronted with errors in ULS Log like:
08.13.2015 16:23:50.93 w3wp.exe (0x56E0) 0x4168 SharePoint Server Workflow Services ajac3 Exception Microsoft.SharePoint.SPException: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator. at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version) at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvider, SPSqlCommand command, Byte[] compositeKey) at Microsoft.SharePoint.AppManagement.AppManagementServiceApplicationProxy.GetApp(String appId) at Microsoft.SharePoint.AppRegistration.GetAppInfo(String appId, Boolean throwIfNotExists) at Microsoft.SharePoint.SPAppPrincipalManager.LookupInInternalDirectory(SPAppPrincipalIdentityProvider identityProvider, String nameIdentifier) at Microsoft.SharePoint.SPAppPrincipalManager.LookupAppPrincipal(SPAppPrincipalIdentityProvider identityProvider, SPAppPrincipalName appPrincipalName) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.<>c__DisplayClassc.<LookupAppPrincipal>b__9(SPWeb elevatedWeb) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.LookupAppPrincipal(SPWeb web, String appId) StackTrace: at Microsoft.Office.Server.Native.dll: (sig=a1000fac-02c7-4003-8d43-320bb54966b7|2|microsoft.office.server.native.pdb, offset=131D6) at Microsoft.Office.Server.Native.dll: (offset=21B79) ee99239d-d16f-4096-26c4-8df19e5fa76a
08.13.2015 16:23:50.94 w3wp.exe (0x0598) 0x5374 SharePoint Foundation Micro Trace uls4 Medium Micro Trace Tags: (none) ee99239d-d16f-4096-26c4-8df19e5fa76a
08.13.2015 16:23:50.94 w3wp.exe (0x56E0) 0x4168 SharePoint Server Workflow Services ahv97 Exception Microsoft.SharePoint.SPException: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator. at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version) at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvider, SPSqlCommand command, Byte[] compositeKey) at Microsoft.SharePoint.AppManagement.AppManagementServiceApplicationProxy.PutApp(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.AppRegistration.AddOrUpdateAppNoPermissionCheck(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.SPAppPrincipalManager.RegisterWithInternalDirectory(SPAppPrincipalIdentityProvider identityProvider, String nameIdentifier, String displayName, List`1 appEndpointAuthorities, List`1 redirectAddresses, Boolean delegateAppPermissions, Boolean isInternalDirectoryApp) at Microsoft.SharePoint.SPAppPrincipalManager.CreateAppPrincipal(SPExternalAppPrincipalCreationParameters creationParameters) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.EnsureAppPrincipal(SPWeb elevatedWeb) StackTrace: at Microsoft.Office.Server.Native.dll: (sig=a1000fac-02c7-4003-8d43-320bb54966b7|2|microsoft.office.server.native.pdb, offset=131D6) at Microsoft.Office.Server.Native.dll: (offset=21B79) ee99239d-d16f-4096-26c4-8df19e5fa76a
08.13.2015 16:23:50.94 w3wp.exe (0x56E0) 0x4168 SharePoint Server Workflow Services ahv97 Exception Microsoft.SharePoint.SPException: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator. at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version) at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvider, SPSqlCommand command, Byte[] compositeKey) at Microsoft.SharePoint.AppManagement.AppManagementServiceApplicationProxy.PutApp(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.AppRegistration.AddOrUpdateAppNoPermissionCheck(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.SPAppPrincipalManager.RegisterWithInternalDirectory(SPAppPrincipalIdentityProvider identityProvider, String nameIdentifier, String displayName, List`1 appEndpointAuthorities, List`1 redirectAddresses, Boolean delegateAppPermissions, Boolean isInternalDirectoryApp) at Microsoft.SharePoint.SPAppPrincipalManager.CreateAppPrincipal(SPExternalAppPrincipalCreationParameters creationParameters) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.EnsureAppPrincipal(SPWeb elevatedWeb) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.<SetupApplicationEcosystem>b__3() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.SetupApplicationEcosystem() StackTrace: at Microsoft.Office.Server.Native.dll: (sig=a1000fac-02c7-4003-8d43-320bb54966b7|2|microsoft.office.server.native.pdb, offset=131D6) at Microsoft.Office.Server.Native.dll: (offset=21B79) ee99239d-d16f-4096-26c4-8df19e5fa76a
08.13.2015 16:23:50.94 w3wp.exe (0x56E0) 0x4168 SharePoint Foundation Runtime tkau Unexpected Microsoft.SharePoint.SPException: We're sorry, we weren't able to complete the operation, please try again in a few minutes. If you see this message repeatedly, contact your administrator. at Microsoft.SharePoint.SPScaleOutDatabaseMap.CreateSqlSession(ISPScaleOutDatabaseMapProvider mapProvider, Byte[] compositeKey, Guid forceRefreshVersion, Guid& version) at Microsoft.SharePoint.SPScaleOutDatabaseCommandExecutor.Execute(ExecuteDelegate operation, ISPScaleOutDatabaseMapProvider mapProvider, SPSqlCommand command, Byte[] compositeKey) at Microsoft.SharePoint.AppManagement.AppManagementServiceApplicationProxy.PutApp(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.AppRegistration.AddOrUpdateAppNoPermissionCheck(SPAppPrincipalInfo appInfo) at Microsoft.SharePoint.SPAppPrincipalManager.RegisterWithInternalDirectory(SPAppPrincipalIdentityProvider identityProvider, String nameIdentifier, String displayName, List`1 appEndpointAuthorities, List`1 redirectAddresses, Boolean delegateAppPermissions, Boolean isInternalDirectoryApp) at Microsoft.SharePoint.SPAppPrincipalManager.CreateAppPrincipal(SPExternalAppPrincipalCreationParameters creationParameters) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.EnsureAppPrincipal(SPWeb elevatedWeb) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.<SetupApplicationEcosystem>b__3() at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.SetupApplicationEcosystem() at Microsoft.SharePoint.WorkflowServices.SPWebWorkflowSecurityContext.ConfigureAppOnlyPolicy(Boolean isAppOnly) at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce) at Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly) at Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, Int32 compatibilityLevel, String featureName, Version version, SPFeaturePropertyCollection properties, SPFeatureActivateFlags activateFlags, Boolean force, Boolean fMarkOnly, Boolean fIgnoreMissing, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, Int32 compatibilityLevel, SPFeatureDefinitionScope featdefScope) at Microsoft.SharePoint.WebControls.FeatureActivatorItem.ToggleFeatureActivation() at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ee99239d-d16f-4096-26c4-8df19e5fa76a
To fix the problem, I had to delete and then redeploy the “App Management Service” Service Application.