在Azure中,我应该在哪里存储需要由Worker角色访问的物理文件?
在我的情况下,我通常会将这些特定文件存储在我的Web角色的App_Data文件夹中,但我不相信Worker Roles可以访问该文件夹.
我正在将现有的Web应用程序(使用Entity Framework 5)迁移到Azure Web角色.
正在将数据库连接字符串从文件移动web.config到ServiceConfiguration.*.cscfg文件.
问题是在自动生成的 Model.Context.cs文件中,我的实体类定义如下:
public partial class MyEntities : DbContext
{
public MyEntities()
: base("name=MyEntities")
{ }
// DbSets, etc
}
Run Code Online (Sandbox Code Playgroud)
这总是会MyEntities在web.config.如何覆盖此构造函数以便我可以从ServiceConfiguration.*.cscfg文件中传入连接字符串?
我可以从这个类中派生出来,就像这样:
public class MyCloudEntities : MyEntities
{
public MyCloudEntities()
: base(CloudConfigurationManager.GetSetting("MyEntities"))
{ }
}
Run Code Online (Sandbox Code Playgroud)
但后来我必须改变MyEntities代码库中的每个实例,并且它不会阻止开发人员MyEntities在将来使用.
entity-framework web-config azure azure-web-roles entity-framework-5
将完整的云服务项目推送到云是非常耗时的,所以如果它有一些小的改变,我希望它们立即反映,那么我将RDP转换为Web角色并进行这些更改并重新启动IIS.也可以为工人角色做这样的事吗?我可以RDP并替换dll文件,但我不知道如何重新启动worker角色,因为它不在IIS上运行.我不确定工作角色是什么运行的?我知道这不是一个好习惯,但由于我还处于开发阶段,这将极大地加快我的测试过程.
有没有简单的方法来更新云上的工作者角色而不是全力推动?
在构建服务器上使用"发布"目标构建云服务(Web角色)项目时,我在CSPack步骤中从构建服务器收到一些奇怪的错误.通过Visual Studio 2012发布工作正常,但不在构建服务器上.
Team City报告的错误:
[Azure\AzureAPI\AzureAPI.ccproj.teamcity] CorePublish
[15:58:49][CorePublish] CorePublish: PackageWebRole = True
[15:58:49][CorePublish] Publishing starting...
[15:58:49][CorePublish] RolePlugins is
[15:58:49][CorePublish] Publishing to 'bin\Release\app.publish\'
[15:58:49][CorePublish] MakeDir
[15:58:49][CorePublish] TargetServiceDefinition is bin\Release\ServiceDefinition.csdef [15:58:49][CorePublish] TargetServiceConfiguration is bin\Release\ServiceConfiguration.cscfg
[15:58:49][CorePublish] Roles is
[15:58:49][CorePublish] CSPack
[15:58:49][CSPack] D:\AzureAPI\bin\Release\ServiceDefinition.csdef error CloudServices077:
Need to specify the physical directory for
the virtual path 'Web/' of role Application.MyWebApi
Run Code Online (Sandbox Code Playgroud)
我的ServiceDefinition文件包含站点的这些设置.
<WebRole name="Application.MyWebApi" vmsize="Small">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="www" />
</Bindings>
</Site>
</Sites>
...
</WebRole
Run Code Online (Sandbox Code Playgroud)
在构建服务器上,我有"Azure Authoring Tools v2.0"和"Windows Azure Libraries for .NET …
我最近将我的azure存储库从1.7升级到2.1,从那时起我就无法部署到我的云服务.我一直得到这个部署错误.
The size of local resources cannot be reduced. Affected local resource is DiagnosticStore in WorkerRole. Current size is 20000. Requested size is 4096.
Run Code Online (Sandbox Code Playgroud)
我没有启用缓存,我尝试使用Small甚至中型VM,但问题仍然存在.知道问题可能在哪里?
我在azurewebsites上有一个简单的mvc网站(使用VS互联网模板),与同一数据中心的SQL Azure数据库通信.此时数据库只是用于内置的SimpleMembership Provider.我已经从默认的App_Data mdf文件切换到Azure SQL.它工作正常,但有时一段时间后,它会给:
建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确,以及SQL Server是否配置为允许远程连接.(提供程序:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)
留言很长:
SQLExpress数据库文件自动创建错误:
连接字符串使用应用程序的App_Data目录中的数据库位置指定本地Sql Server Express实例.提供程序尝试自动创建应用程序服务数据库,因为提供程序确定数据库不存在.要成功检查应用程序服务数据库是否存在并自动创建应用程序服务数据库,必须满足以下配置要求:
但我没有使用SQL Server Express的连接字符串!
立即重新启动网站不会删除错误.
没有改变任何东西并在15分钟后重新启动网站给出:
502 - Web服务器在充当网关或代理服务器时收到无效响应.
您正在查找的页面存在问题,无法显示.当Web服务器(充当网关或代理)与上游内容服务器联系时,它从内容服务器收到无效响应.
以前,我可以通过从VS重新发布将网站恢复到正常工作状态.但是在过去的一个小时里,我尝试过并尝试过,我无法让网站再次运行.
SQL Server Express真的有什么问题?
我的连接字符串部分包含:
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=tcp:sabl6h4---.database.windows.net,1433;Database=MVC;User ID=test@sabl6h4---;Password=----;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
<add name="Entities" connectionString="metadata=res://*/Data.Model1.csdl|res://*/Data.Model1.ssdl|res://*/Data.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=sabl6h4---.database.windows.net;initial catalog=MVC;user id=test;password=----;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
为了确保,我将sabl6h4---.database.windows.net复制并粘贴到SSMS中并使用登录测试进行连接,并且没有问题地打开了数据库.
一天后:我创建了一个新的azurewebsite并发布了完全相同的项目和相同的web.config.它没有问题,工作正常.几分钟后,发生了完全相同的错误!
再过三个小时:去吃午饭,回来,点击浏览器刷新按钮,网站再次启动.我确信有人在后端的设置中鬼混.
asp.net-mvc entity-framework connection-string azure-web-roles azure-sql-database
我正在开发一个MVC4应用程序,它使用ADFS验证corp域用户,我编写了代码,我收到如下错误,我没有得到索赔?
System.InvalidCastException:无法将类型为"System.Security.Claims.ClaimsPrincipal"的对象强制转换为"Microsoft.IdentityModel.Claims.IClaimsPrincipal".
public ActionResult Index()
{
try
{
IClaimsPrincipal principal = (IClaimsPrincipal)Thread.CurrentPrincipal;
IClaimsIdentity identity = (IClaimsIdentity)principal.Identity;
if (String.IsNullOrEmpty(identity.Claims[0].Value.Split('@')[0]))
{
ViewData["Message"] = string.Format("You are email is :{0}", identity.Claims[0].Value.Split('@')[0]);
}
else
{
ViewData["Message"] = "You are not getting any claims";
}
}
catch (Exception ex)
{
ViewData["Message"] = "Something wrong.";
}
return View();
}
Run Code Online (Sandbox Code Playgroud) 使用http://docs.orchardproject.net/Documentation/Deploying-Orchard-to-Windows-Azure我已成功将Orchard部署到Azure中.
每20分钟左右没有活动(app pool recycle?),渲染页面需要几分钟.我在Azure中运行Extra Small实例.Web实例,存储和SQL数据库都在同一个数据中心 - 东南亚.
有一个名为keepalive的模块,它执行常规ping操作.
或http://blog.smarx.com/posts/controlling-application-pool-idle-timeouts-in-windows-azure
同时关闭Debug(!)并完全信任,如此处所述http://docs.orchardproject.net/Documentation/Optimizing-Performance-of-Orchard-with-Shared-Hosting
将尝试设置/预热页面..
ping似乎很重 - 我错过了什么吗?
使用VS2012我从WebRole属性缓存选项卡添加了缓存功能.其中,它在web.config中生成以下XML:
<dataCacheClients>
<tracing sinkType="DiagnosticSink" traceLevel="Error" />
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="[cluster role name]"/>
<!-- <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" /> -->
</dataCacheClient>
</dataCacheClients>
Run Code Online (Sandbox Code Playgroud)
好,太棒了.我将[cluster role name]替换为webrole的名称,例如"helloworld.web".现在,当我创建DataCacheFactory或DataCache对象时:
_dataCacheFactory = new DataCacheFactory();
_defaultCache = _dataCacheFactory.GetDefaultCache();
//Or, just this line
_defaultCache = new DataCache(@"default");
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Microsoft.ApplicationServer.Caching.DataCacheException was unhandled
HelpLink=http://go.microsoft.com/fwlink/?LinkId=164049
HResult=-2146233088
Message=ErrorCode<ERRCA0021>:SubStatus<ES0001>:Server collection cannot be empty.
Source=Microsoft.ApplicationServer.Caching.Client
ErrorCode=21
SubStatus=-1
Some notes:
IDE: VS2012,
Framework: 4.0
AzureSDK: June2012
Local dev machine
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
编辑
我得到了它的工作!
我在WebRole OnStart方法中创建了DataCacheFactory,我将它移到了Global.asax中的Application_Start,它似乎正在工作.
Sandrino解释了为什么会出现这种情况:https://stackoverflow.com/a/11886136/1374935
我的WebRole尝试启动时出现以下异常:
{"无法加载文件或程序集'Microsoft.WindowsAzure.Diagnostics,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.(例外情况HRESULT:0x80131040)":"Microsoft.WindowsAzure.Diagnostics,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35"}
我将Visual Studio 2012与Azure SDK 2.1一起使用
azure-web-roles ×10
azure ×9
c# ×4
.net ×1
asp.net-mvc ×1
caching ×1
iis ×1
orchardcms ×1
teamcity ×1
web-config ×1