2. Хостинг веб-приложений в Azure
Конфигурирование и публикация веб-приложений
Мониторинг и анализ развернутых веб-приложений
Обзор облачных сервисов
Веб-роли и рабочие роли. Экземпляры ролей
Настройка облачных сервисов
Обновление сервисов и управление их
развертыванием
8. Веб-приложения используют ресурсы в
соответствии с пятью уровнями:
Premium (enterprise)
Подробнее – здесь: https://azure.microsoft.com/en-us/pricing/details/app-service/
9. Для хостинга нескольких веб-приложений
используйте план Basic или Standard
BasicStandard Shared FreePremium
10.
11.
12. Пакет приложения и его конфигурация хранятся на
внешнем хранилище
App Settings и Connection Strings перехватываются
и заменяются в процессе старта
Пути масштабирования приложений:
14. Хостинговые планы могут логически группировать
веб-приложения в рамках подписки
В одной ресурсной группе могут существовать
несколько хостинговых планов
Несколько веб-приложений могут существовать в
одном хостинговом плане
18. Доступно начиная с плана Basic/Standard
Идеальный выбор для постоянной
продолжительной обработки запросов
Регулярно генерирует простой HTTP-запрос
19. Стандартный домен
Начиная с режима Shared Вы можете настроить
приложение на использование другого доменного
имени
Traffic Manager поддерживает другие доменные
имена
24. Web Deploy упрощает развертывание веб-
приложений на IIS, предоставляя стандартный
формат пакета
Visual Studio и WebMatrix поддерживают
развертывание веб-приложений через Web Deploy
25.
26. App settings и connection strings можно задать и
управлять ими через портал
32. Облачный сервис в Azure состоит из трех частей:
Новая виртуальная машина создается каждый
раз, когда сервис создается, перезапускается или
масштабируется; на каждую машину
разворачиваются бинарники
41. Преднастроенный Windows Server
Больше ничего не установлено
Нет стандартных точек подключения
Может содержать все, что не требует
наличия IIS
Установка дополнительного ПО
через скрипты
Логика содержится в классе –
наследнике WorkerRole.cs
42. Изолированный модуль, который может иметь
несколько экземпляров
Для запросов используется внешнее хранилище
Worker Role может быть хостом для WCF-сервиса
для получения запросов
43.
44. Воркер-роль обычно реализует простой паттерн
Приостановить
поток
Проверить наличие
новых сообщений
в хранилище
Обработать
сообщение
Пометить
сообщение как
обработанное
45.
46. Сборка Microsoft.WindowsAzure.ServiceRuntime
входит в состав Azure SDK
Сборка содержит пространство имен
Microsoft.WindowsAzure.ServiceRuntime которое
включает классы для управления ролями
Класс RoleEntryPoint (базовый для обеих видов
ролей) также содержится здесь
47.
48. Каждая роль содержит класс – наследник базового
класса
Класс RoleEntryPoint содержит методы управления
жизненным циклом, которые могут быть
переопределены в дочерних классах
Azure берет первый найденный ею класс – наследник
RoleEntryPoint и выполняет его методы в таком порядке
50. В методе Run() Вы можете использовать
бесконечный цикл для опроса состояния внешнего
хранилища и получения из него одного или
нескольких необработанных сообщений
https://azure.microsoft.com/en-
us/documentation/articles/cloud-services-role-lifecycle-dotnet/
51. Загрузка пакета
с сервисом
в Azure
Создание
виртуальных машин
Роли запускаются
RoleEntryPoint
OnStart()
RoleEntryPoint Run()
Web или worker
роли запущены
[Role Recycle]
RoleEntryPoint
OnStop()
[Role Recycle]
Роль удаляется из
балансировщика
нагрузки
52.
53. Для каждой роли можно
увеличить количество
экземпляров (в свойствах)
Для облачных сервисов
могут быть созданы
виртуальные машины
разных размеров
55. Local storage внутри роли описывается в XML-файле
описания сервиса
Local storage резервирует каталог в файловой системе
если приложению нужно читать или модифицировать
файл
Local storage может сохраняться на протяжении всего
жизненного цикла экземпляра роли, но это не
гарантируется!
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-configure-local-storage-resources/
56. Можно собирать диагностические данные об
облачном сервисе в хранилище (storage account)
https://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/
60. Для существующего сервиса можно загрузить
обновленный файл конфигурации
Новый пакет и файл конфигурации можно
загрузить в промежуточную среду (Staging Slot)
Staging Production
Demonstration Steps
On the Start screen, click the Internet Explorer tile.
Go to https://portal.azure.com.
In the email address box, type the email address of your Microsoft account
Click Continue.
In the password box, type your password for your Microsoft account.
Click Sign In.
At the lower-left corner of the screen, click New.
In the New blade that displays, click Everything.
In the Marketplace blade that displays, click Web.
Under the Recommended section, click Website + SQL.
In the Website + SQL blade that displays, click Create.
In the Website + SQL blade that displays, perform the following steps:
In the Resource Group box, type rg20532.
Click Website.
In the Website blade that displays, locate the URL box.
In the URL box, type a unique name for your Website.
Click OK.
In the Website + SQL blade, click Database.
In the New database blade that displays, locate the Name box.
In the Name box, type rg20532db.
Click Server.
In the New server blade that displays, locate the Server Name box.
In the Server Name box, type a unique name for your logical server.
In the Server Admin Login box, type testuser.
In the Password box, type TestPa$$w0rd.
In the Confirm Password box, type TestPa$$w0rd.
Click OK.
In the New database blade, click OK.
In the Website + SQL blade, click Create to create your Resource Group.
After the Resource Group is created, the rg20532 blade will automatically display for your new Website.
In the rg20532 blade that displays, click the icon of the new Website resource that you created.
Note: The Summary area contains icons for each resource in your Resource Group. The single Website resource is the icon you should select.
In the new blade that displays, click the Settings tile.
In the Settings blade that appears, click the Properties button.
*см. модуль 1 – шаблоны роста количества запросов (выключено и включено, быстрый рост, непредсказуемый всплеск, предсказуемые всплески)
Demonstration Steps
On the Start screen, click the Internet Explorer tile.
Go to https://portal.azure.com.
Enter the email address of your Microsoft account..
Click Continue
Enter the password for your Microsoft account..
Click Sign In
At the lower-left corner of the screen, click New.
In the New blade that displays, click the Website option.
In the Website blade that displays, perform the following steps:
In the URL box, provide a unique name for your website.
Click Web Hosting Plan.
In the Web Hosting Plan blade, locate the Name box, and type Autoscale.
Locate and select the S1 Standard size option.
Click OK.
In the Website blade, click Create.
Demonstration Steps
On the Start screen, click the Internet Explorer tile.
Go to https://portal.azure.com.
Enter the email address of your Microsoft account..
Click Continue.
Enter the password for your Microsoft account.
Click Sign In.
At the bottom-left corner of the screen, click New.
In the New blade that displays, click Website.
In the Website blade that displays, do the following:
In the URL dialog box, provide a unique name for your website.
Click Create.
After the Website is created, the new website blade will automatically open.
In the new blade that displays for your website, perform the following steps:
Click the Settings tile.
In the Settings blade, click Application Settings.
Locate the Connection strings section, and then add a connection string using the Name entrycount and the Value 8.
Locate the App settings section, and add an app setting using the Key externaldatabase and the Value URL=http://dataService;Data Format=JSON;Auto Cache=true;.
Click the SAVE button at the top of the blade.
Close Internet Explorer.
Создать два проекта – облачных сервиса. Для веб- (добавить WebAPI-проект, убрать атрибут Autorize с Value-контроллера) и воркер-роли и показать, что оба класса (workerrole, webrole)– наследники стандартного, показать код, запустить (воркер-роль – в UI эмулятора, веб- в браузере дописать /api/values)…
Demonstration Steps
On the Start screen, right-click the Visual Studio 2013 tile.
In the app bar, click Run as Administrator.
Note: If the User Account Control (UAC) dialog box that displays, you can elevate the permissions to run
Visual Studio 2013 as an administrator.
On the Visual Studio start screen, click New Project.
In the New Project dialog box, perform the following steps:
Expand Installed, Templates, Visual C#, and then click Cloud.
Click the Azure Cloud Service template.
In the Name box, type WorkerDemo.
Click OK.
In the New Microsoft Azure Cloud Service dialog, double-click the Worker Role option in the .NET Framework 4.5 roles section.
Observe that a new Worker Role instance is created in the Microsoft Azure Cloud Service solution section named WorkerRole1.
Right-click the WorkerRole1 instance and click Rename.
Provide the value ConsoleRole and use the Enter key.
Double-click the ASP.NET Web Role option in the .NET Framework 4.5 roles section.
Observe that a new Web Role instance is created in the Microsoft Azure Cloud Service solution section named WebRole1.
Right-click the WebRole1 instance and click Rename.
Provide the value ASPRole and use the Enter key.
Click the OK button.
In the New ASP.NET Project – ASPRole dialog, click the OK button.
In the Solution Explorer pane, expand the ConsoleRole project.
Double-click the WorkerRole.cs item.
In the Solution Explorer pane, expand the ASPRole project.
Double-click the WebRole.cs item.
Close the WorkerDemo – Microsoft Visual Studio application.
The role recycles when the call to RoleEntryPoint Run() returns. Make sure you don’t exit the application or have unhandled exceptions because this would cause a loop of role recycles.