WindowsAzure:是否可以在web.config中设置目录权限? [英] WindowsAzure: Is it possible to set directory permissions within the web.config?

查看:146
本文介绍了WindowsAzure:是否可以在web.config中设置目录权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的PHP脚本想要写入日志文件夹,结果错误是:


无法打开日志文件E :\ approot \ framework \ log / dev.log用于写作。


当我为WebRole设置写入权限时用户RD001 ...手动它工作正常。
现在我想自动设置文件夹权限。有一个简单的方法来完成它吗?
请注意我对IIS和周围的东西都很新,我会很感激准确的答案,谢谢。

解决方案

简短/技术响应



您可以使用完全信任和启动设置来设置特定文件夹的权限。但是,您需要在此脚本中考虑无状态操作系统和更改驱动器号(可能,不太可能),这将使其变得困难。此外,本地存储不会保留,因此您无法确保在重新启动时保留此数据。



建议 :不要写本地,请阅读以下内容...



编辑:想到这一点,虽然我仍然建议不要这样做,但有第三种选择:你可以在服务配置中分配本地存储,然后使用dll引用从PHP访问它,然后您就可以访问该文件夹。请记住,本地存储不会保留,因此在重新启动时它已经消失。



本地服务配置:
http://blogs.mscommunity.net/blogs/dadamec/ archive / 2008/12/11 / azure-reading-and-writing-with-localstorage.aspx



从php访问配置:
< a href =http://phpazure.codeplex.com/discussions/64334?ProjectName=phpazure =nofollow> http://phpazure.codeplex.com/discussions/64334?ProjectName=phpazure






长/详细回复:



<在Azure中,我们鼓励您作为平台而不是服务器上的软件来处理事物。我的意思是,诸如将内容写入本地日志文件之类的想法与云想法有些不相容。根据您的使用情况,您可以(并且应该)转换此脚本以将此数据输出到某些基于云的存储或外部存储,而不是将其放在磁盘上。



我建议修改此脚本以利用PHP Azure SDK并将这些日志条目写入Azure中的表或blob存储。如果这听起来不错,请提供PHP,我可以给出一个确切的例子。



主要原因(除了推动云的想法)是在Azure中,您不能假设主机(角色实例)将保持操作系统状态,因此虽然您可以设置一些诸如文件夹权限之类的东西,但您不能依赖它们坚持这种方式。当结构必须更新您的角色并对某些较低级别的问题做出反应时,您没有真正的方法可以保证不会重置这些权限。例如,当前实例所在的机架上的硬盘驱动器笼可能会失败。如果故障足够严重,Fabric控制器将需要重建您的实例。当发生这种情况时,您的代码将被移动到完全不同的服务器,因此需要重新设置这些权限。此外,根据更改,E:\可能突然需要是F:\或X:\驱动器,你不会知道。



更好地假装(在某种程度上)您的应用程序在Azure中运行而不是在Azure上的服务器上,因此您不会对托管环境做出任何假设。因此,您需要在代码之外的任何内容(数据,日志,审核等)应存储在您可以控制的地方(Azure存储,外部呼出等)


A PHP scriptof mine wants to write into a log folder, the resulting error is:

Unable to open the log file "E:\approot\framework\log/dev.log" for writing.

When I set the writing permissions for the WebRole User RD001... manually it works fine. Now I want to set the folder permissions automatically. Is there an easy way to get it done? Please note that I'm very new to IIS and the stuff around, I would appreciate precise answers, thx.

解决方案

Short/Technical Response:

You could probably set permissions on a particular folder using full-trust and a startup taks. However, you'd need to account for a stateless OS and changing drive letters (possible, not likely) in this script, which would make it difficult. Also, local storage is not persisted, so you'd have no way to ensure this data stayed in the case of a reboot.

Recommendation: Don't write local, read below ...

EDIT: Got to thinking about this, and while I still recommend against this, there is a 3rd option: You can allocate local storage in the service config, then access it from PHP using a dll reference, then you will have access to that folder. Please remember local storage is not persisted, so it's gone during a reboot.

Service Config for local: http://blogs.mscommunity.net/blogs/dadamec/archive/2008/12/11/azure-reading-and-writing-with-localstorage.aspx

Accessing config from php: http://phpazure.codeplex.com/discussions/64334?ProjectName=phpazure


Long / Detailed Response:

In Azure, you really are encouraged to approach things as a platform and not as "software on a server". What I mean there is that ideas such as "write something to a local log file" are somewhat incompatible with the cloud "idea". Depending on your usage, you could (and should) convert this script to output this data to some cloud-based or external storage, vs just placing it on the disk.

I would suggest modifying this script to leverage the PHP Azure SDK and write these log entries out to table or blob storage in Azure. If this sounds good, please provide the PHP and I can give an exact example.

The main reason for that (besides pushing the cloud idea) is that in Azure, you cannot assume the host machine ("role instance") will maintain an OS state, so while you can set some things such as folder permissions, you can't rely on them sticking that way. You have no real way to guarantee those permissions won't be reset when the fabric has to update your role and react to some lower level problem. For example, a hard-drive cage on the rack where your current instance lives could fail. If the failure were bad enough, the Fabric controller would need to rebuild your instance. When that happens, your code is moved to an entirely different server, so the need would arise to re-set those permissions. Also, depending on the changes, the E:\ could all of a sudden need to be the F:\ or X:\ drive and you wouldn't know.

Its much better to pretend (at some level) that your application is running "in Azure" and not "on a server in azure", so you make no assumptions about the hosting environment. So anything you need outside of your code (data, logs, audits, etc) should be stored somewhere you can control (Azure Storage, external call-out, etc)

这篇关于WindowsAzure:是否可以在web.config中设置目录权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆