【问题标题】:Access Denied on Web.config Azure Web RoleWeb.config Azure Web 角色上的访问被拒绝
【发布时间】:2016-01-04 19:39:51
【问题描述】:

我的 Azure Web 角色突然停止工作并出现以下错误。
“访问路径 'F:\sitesroot\0\Web.config' 被拒绝。”
最近没有发布任何更改或配置,直到昨天它都可以正常工作!我检查了 Web.config 的权限,我看到所有用户都有读取/执行权限。这是堆栈跟踪:

    [UnauthorizedAccessException: Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +216
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1430
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +205
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +87
   System.IdentityModel.Tokens.UpdateValidatingIssuerNameRegistry.FlushDocument(String originalXml, String location) +218
   System.IdentityModel.Tokens.UpdateValidatingIssuerNameRegistry.UpdateIssuerNameRegistryElement(String pathToConfig, String fedMetadataAddress, String serviceName) +493
   Manager.MvcApplication.RefreshValidationSettings() in c:\GitHub\mfs_backoffice\2013_2.2\KCI.MFS.Manager\ManagerMFS\Global.asax.cs:37
   Manager.MvcApplication.Application_Start() in c:\GitHub\mfs_backoffice\2013_2.2\KCI.MFS.Manager\ManagerMFS\Global.asax.cs:30

[HttpException (0x80004005): Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12601629
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618676
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458293  

更新:
在遇到问题后,我还重新启动、重新映像并重新部署了实例,但都没有成功。我还尝试将我的文件复制到实例上的不同位置(在 D 驱动器中)并将其作为另一个站点添加到 IIS,但是当我尝试浏览它时它仍然给我同样的错误

【问题讨论】:

  • 您是否对您的 Web 角色实例进行了 RDP,以确认驱动器号仍然是 f: 并且没有更改为 e: ?
  • 是的,仍然是 f:@DavidMakogon

标签: c# asp.net azure iis azure-web-roles


【解决方案1】:

解决我们的问题:

问题是我们正在修改 ApplicationStart() 方法中的 Web.config 以根据 Microsoft 建议的滚动新公钥的方法滚动我们的密钥:Important Information About Signing Key Rollover in Azure AD

    protected void RefreshValidationSettings()
    {
        string configPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + "Web.config";
        string metadataAddress = ConfigurationManager.AppSettings["ida:FederationMetadataLocation"];
        ValidatingIssuerNameRegistry.WriteToConfig(metadataAddress, configPath);
    }

所以我停止使用 Microsoft 方法来滚动公钥,它解决了这个问题(现在我们需要每六个月手动更新一次公钥)。但是我找不到 Azure Web 角色上的权限策略发生更改的原因

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 2018-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多