Skip to content

WebJob Sample

cdmdotnet edited this page Jul 25, 2017 · 9 revisions

Your Azure micro-service application

Congratulations! You've created a project. You can launch and publish your app once you've configured it using the instructions below.

CONFIGURE YOUR APP FOR LOCAL DEVELOPMENT

Use the same connection string for all files below.

  1. RestAPI - web.config
    1. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.CommandBus.ConnectionString".
    2. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.EventBus.ConnectionString".
    3. Set the SQL Server connection string for connection string named "Logs".
    4. Set the SQL Server connection string for connection string named "DataStore"
    5. Set the SQL Server connection string for connection string named "EventStore"
  2. MicroKernel - app.config
    1. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.CommandBus.ConnectionString".
    2. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.EventBus.ConnectionString".
    3. Set the SQL Server connection string for connection string named "Logs".
    4. Set the SQL Server connection string for connection string named "DataStore"
    5. Set the SQL Server connection string for connection string named "EventStore"
    6. Set the Storage Account connection string for connection string named "AzureWebJobsDashboard"
    7. Set the Storage Account connection string for connection string named "AzureWebJobsStorage"
  3. WcfAPI - web.config
    1. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.CommandBus.ConnectionString".
    2. Set the Azure Service Bus connection string for application settings "Cqrs.Azure.EventBus.ConnectionString".
    3. Set the SQL Server connection string for connection string named "Logs".
    4. Set the SQL Server connection string for connection string named "DataStore"
    5. Set the SQL Server connection string for connection string named "EventStore"
  4. Execute the following SQL scripts:
    1. Run SQL scripts:
      1. \MicroServices\tools\ConversationSummary.sql
      2. \MicroServices\tools\Credentials.sql
      3. \MicroServices\tools\Messages.sql
      4. \MicroServices\tools\Users.sql
    2. Run CQRS SQL scripts:
      1. \MicroServices\tools\Create-Log-Table.sql
      2. \MicroServices\tools\EventStoreTable-SqlServer.sql
  5. Compile all projects.
  6. Run the MicroKernel console app first and leave it running. In Azure this runs as a WebJob.
    1. By default the application setting "CreateTestData" in MicroKernel - app.config is set to true, which means each time the app is started all data will be flushed and re-populated.
  7. Start/visit the UI website.

CONFIGURE YOUR APP FOR DEPLOYMENT TO AZURE

  1. Create a new Azure SQL Database:
    1. Run SQL scripts:
      1. \MicroServices\tools\ConversationSummary.sql
      2. \MicroServices\tools\Credentials.sql
      3. \MicroServices\tools\Messages.sql
      4. \MicroServices\tools\Users.sql
    2. Run CQRS SQL scripts:
      1. \MicroServices\tools\Create-Log-Table.sql
      2. \MicroServices\tools\EventStoreTable-SqlServer.sql
  2. Create an new instance of Azure Service Bus
  3. Create a Azure Storage Account
  4. Create Website/App Service
    1. Set WebSockets to On Site Settings
    2. Set Always On to On
    3. Set ARR Affinity to Off
    4. Add Azure Service Bus connection strings in App settings: Application Settings
      1. Cqrs.Azure.CommandBus.ConnectionString
      2. Cqrs.Azure.EventBus.ConnectionString
    5. Add Azure Storage Account connection strings for the Azure WebJob: Connection String Settings
      1. AzureWebJobsDashboard
      2. AzureWebJobsStorage
    6. Add database connection strings:
      1. DataStore Connection String Settings
      2. EventStore
      3. Logs
    7. Add virtual folders: If you get the following error while publishing to Azure "Web deployment task failed. (Creating a new application is not supported by this server environment.)" Confirm the below virtual applications are correctly setup first. Virtual Directory Settings
      1. /Chat
        1. Directory: "site\wwwroot"
        2. Application turned Off
      2. /Chat/UI
        1. Directory: "site\UI"
        2. Application turned On
      3. /Chat/RestAPI
        1. Directory: "site\RestAPI"
        2. Application turned On
      4. /Chat/WcfAPI
        1. Directory: "site\WcfAPI"
        2. Application turned On
  5. Update the follow files with the above app settings and connection strings so you can run you application locally:
    1. RestAPI\web.config
    2. WcfAPI\web.config
    3. WcfAPI.Tests\app.config
    4. MicroKernel\app.config
  6. Make sure you start the micro-kernel (it's a console application) first.
    1. The app setting CreateTestData control if the database gets cleared/flushed of all data and populated with fresh data each time it starts. Change this to false if you want to.

DEPLOY

  • Open the WebDeploy.pubxml WebDeploy publishing profiles in each project and replace any reference to cqrs-chat with the name of your Azure App Service created in step 4 of Configure you app.
  • Publish the following project to Azure using the provided WebDeploy publishing profiles:
    • Chat.RestAPI
    • Chat.WcfAPI
    • Chat.UI
    • Chat.MicroKernel
Clone this wiki locally