在Azure中公开提供NodeJS应用程序

时间:2016-04-25 21:42:44

标签: node.js azure azure-web-sites

我正在构建一个azure模板(https://github.com/kevinday/azure-quickstart-templates/blob/master/augur-on-ubuntu/azuredeploy.json),它将在Ubuntu VM中运行nodejs应用程序。

npm start

augur-ui@2.0.0 start /root/augur
http-server ./build -c-1 -p $PORT

Starting up http-server, serving ./build
Available on:
http://127.0.0.1:true
http://10.0.0.4:true
Hit CTRL-C to stop the server

我想将http流量公开给我配置的dns名称http://dnsname.eastus.cloudapp.azure.com

我已经看到了在门户网站中建议配置和端点的文档,但我不再看到此选项。有人能指出我正确的方向来修改我的模板,以便正确配置这个端点吗?

2 个答案:

答案 0 :(得分:0)

您需要在网络安全组中创建入站规则,以允许端口80上的流量。

{
  "apiVersion": "[variables('apiVersion')]",
  "type": "Microsoft.Network/networkSecurityGroups",
  "name": "[variables('networkSecurityGroupName')]",
  "location": "[resourceGroup().location]",
  "properties": {
    "securityRules": [
      {
        "name": "httpRule",
        "properties": {
          "description": "httpRule",
          "protocol": "Tcp",
          "sourcePortRange": "*",
          "destinationPortRange": "80",
          "sourceAddressPrefix": "*",
          "destinationAddressPrefix": "*",
          "access": "Allow",
          "priority": 110,
          "direction": "Inbound"
        }
      }
    ]
  }
}

此处提供了包含NSG和入站规则的完整模板示例:https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-security-group-create/azuredeploy.json

有关Azure网络安全组的详细信息,请参阅:https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/

答案 1 :(得分:0)

众所周知,您可以尝试创建[Win32Exception (0x80004005): The wait operation timed out] [SqlException (0x80131904): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=4223; handshake=2965; ] System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +356 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +117 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +267 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +318 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +211 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +393 System.Data.SqlClient.SqlConnection.Open() +122 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +104 System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +509 System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection) +335 System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +15 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +238 System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction) +271 System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto) +1232 System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) +524 System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +193 System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) +609 System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +613 System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +116 System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) +156 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +72 System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +483 System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +177 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +274 System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes() +63 System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext() +31 OfficeTrack.DAL.Context.MasterContext..ctor() +47 OfficeTrack.Web.MvcApplication.Application_Start() +206 [HttpException (0x80004005): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=4223; handshake=2965; ] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +544 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +186 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343 [HttpException (0x80004005): Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=4223; handshake=2965; ] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712 NSG-FrontEnd以允许HTTP流量到FrontEnd子网。

请参阅文档How to create NSGs using a template以了解如何使用ARM进行此操作。

以下是一个示例ARM模板代码段。

web-rule
相关问题