|  | 
| 1 |  | -# Stages | 
|  | 1 | +## Stages | 
| 2 | 2 | 
 | 
| 3 | 3 | 1. Get a current Azure state. Each resource has a function to get information from Azure. | 
| 4 | 4 |    The function is an asynchronous operation. | 
|  | 
| 7 | 7 |    All decisions has to be made on this stage. | 
| 8 | 8 | 3. Create a graph of create/update operations. This operation is synchronous. | 
| 9 | 9 | 4. Execute the graph. This operation is asynchronous and may require a progress bar, AsJob etc. | 
| 10 |  | -   It can also create several resources simultaneously. | 
|  | 10 | +   It can also create several resources simultaneously. | 
|  | 11 | + | 
|  | 12 | +## Policies | 
|  | 13 | + | 
|  | 14 | +```cs | 
|  | 15 | +interface IInfoMap | 
|  | 16 | +{ | 
|  | 17 | +    Info Get<Info>(IResourcePolicy<Info> info) | 
|  | 18 | +        where Info : class; | 
|  | 19 | +} | 
|  | 20 | +interface IResourcePolicy | 
|  | 21 | +{ | 
|  | 22 | +} | 
|  | 23 | +interface IResourcePolicy<Info> : IResourcePolicy | 
|  | 24 | +    where Info : class | 
|  | 25 | +{ | 
|  | 26 | +    IEnumerable<IResourcePolicy> Dependencies { get; } | 
|  | 27 | +    string GetLocation(Info info); | 
|  | 28 | +    Task<Info> CreateAsync(Context context, Info info); | 
|  | 29 | +} | 
|  | 30 | +interface IResourcePolicy<Info, Id> : IResourcePolicy<Info> | 
|  | 31 | +    where Info : class | 
|  | 32 | +{ | 
|  | 33 | +    Task<Info> GetAsync(Context context, Id id); | 
|  | 34 | +} | 
|  | 35 | +sealed class ManagedResourceId | 
|  | 36 | +{ | 
|  | 37 | +    string ResourceGroupName { get; } | 
|  | 38 | +    string Name { get; } | 
|  | 39 | +} | 
|  | 40 | +interface IManagedResourcePolicy<Info> : IResource<Info, ManagedResourceId> | 
|  | 41 | +{ | 
|  | 42 | +	ResourceGroupPolicy | 
|  | 43 | +    void UpdateInfo(Info info, IInfoMap infoMap); | 
|  | 44 | +} | 
|  | 45 | +interface IResourceGroupPolicy : IResourcePolicy<ResourceGroup, string> | 
|  | 46 | +{ | 
|  | 47 | +} | 
|  | 48 | +interface ISubresource<Info, ParentInfo> : IResource | 
|  | 49 | +{ | 
|  | 50 | +    IResource<ParentInfo> Parent { get; } | 
|  | 51 | +    Info Get(ParentInfo parentInfo); | 
|  | 52 | +    void Set(ParentInfo info, Info info); | 
|  | 53 | +} | 
|  | 54 | +``` | 
0 commit comments