|
| 1 | +<h2>Azure Functions</h2> |
| 2 | +<div style="margin-left:18px;"> |
| 3 | +The Mock Data Recipient solution contains azure function projects.<br /> |
| 4 | +The DiscoverDataHolders function is used to get the list of Data Holder Brands<br /> |
| 5 | +from the Mock Register and update the Mock Data Recipient repository DataHolderBrands table.<br /> |
| 6 | +The DCR function is used to register the software product included in the Mock Data Recipient<br /> |
| 7 | +with the newly discovered Data Holder Brands from the Mock Register.<br /> |
| 8 | +</div> |
| 9 | + |
| 10 | +<h2>To Run and Debug Azure Functions</h2> |
| 11 | +<div style="margin-left:18px;"> |
| 12 | + The following procedures can be used to run the functions in a local development environment for evaluation of the functions. |
| 13 | +<br /> |
| 14 | + |
| 15 | +<div style="margin-top:6px;"> |
| 16 | +1) Start the Mock Register, Mock Data Holder, Mock Data Holder Energy and Mock Data Recipient solutions. |
| 17 | +</div> |
| 18 | +<div style="margin-left:18px;"> |
| 19 | + Noting that the Mock Data Recipient must be running as it is required for the https://localhost:9001/jwks<br /> |
| 20 | + endpoint that is used for the Access Token.<br /> |
| 21 | +</div> |
| 22 | + |
| 23 | +<div style="margin-top:6px;"> |
| 24 | +2) Start the Azure Storage Emulator (Azurite): |
| 25 | +</div> |
| 26 | +<div style="margin-left:18px;margin-bottom:6px;"> |
| 27 | + using a MS Windows command prompt:<br /> |
| 28 | +</div> |
| 29 | + |
| 30 | +``` |
| 31 | +md C:\azurite |
| 32 | +cd "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator" |
| 33 | +azurite --silent --location c:\azurite --debug c:\azurite\debug.log |
| 34 | +``` |
| 35 | + |
| 36 | +<div style="margin-left:18px;"> |
| 37 | + Noting this is only required to be performed once, it will then be listening on ports - 10000, 10001 and 10002<br /> |
| 38 | + when debugging is started from MS Visual Studio by selecting CDR.DiscoverDataHolder or CDR.DCR as the startup project<br /> |
| 39 | + (by starting a debug instance using F5 or Debug > Start Debugging) |
| 40 | + <br /> |
| 41 | +</div> |
| 42 | +<div style="margin-left:18px;margin-bottom:6px;"> |
| 43 | + or by using a MS Windows command prompt:<br /> |
| 44 | +</div> |
| 45 | + |
| 46 | +``` |
| 47 | +navigate to .\mock-data-holder-energy\Source\CDR.GetDataRecipients<br /> |
| 48 | +func start --verbose<br /> |
| 49 | +``` |
| 50 | + |
| 51 | +<div style="margin-left:18px;"> |
| 52 | + To reset the message queue, uncomment the following line of code and start the debug instance as indicated above, placing a<br /> breakpoint after this code;<br /> |
| 53 | + await DeleteAllMessagesAsync(log, qConnString, qName);<br /> |
| 54 | +</div> |
| 55 | + |
| 56 | +<div style="margin-top:6px;"> |
| 57 | +3) Open two instances of Mock Data Recipient in MS Visual Studio, |
| 58 | +</div> |
| 59 | +<div style="margin-left:18px;"> |
| 60 | + (select CDR.DCR as the startup project in one and CDR.DiscoverDataHolder as the startup project in the other) |
| 61 | +</div> |
| 62 | + |
| 63 | +<div style="margin-top:6px;"> |
| 64 | +4) Start each debug instances (F5 or Debug > Start Debugging), this will simulate the discovery of Data Holder brands and the |
| 65 | +</div> |
| 66 | +<div style="margin-left:18px;"> |
| 67 | + processing of the messages added to the queue. |
| 68 | +</div> |
| 69 | + |
| 70 | +<div style="margin-left:18px;margin-top:12px;margin-bottom:6px;"> |
| 71 | + Noting the below sql script is used to clear out the registrations as the seed data is not a good reflection on reality as the<br /> infosecBaseUri values are either invalid or duplicated, so running this script resets the data so the registration process can<br /> |
| 72 | + occur for the processed message queue item. |
| 73 | +</div> |
| 74 | + |
| 75 | +``` |
| 76 | +DECLARE @i INT = 1; |
| 77 | +WHILE (@i <= 3600000) |
| 78 | +BEGIN |
| 79 | +WAITFOR DELAY '00:00:01' |
| 80 | + DELETE FROM [cdr-mdr].[dbo].[Registration] |
| 81 | + DELETE FROM [cdr-idsvr].[dbo].[Clients] |
| 82 | + DELETE FROM [cdr-idsvre].[dbo].[Clients] |
| 83 | +SET @i = @i + 1; |
| 84 | +END |
| 85 | +
|
| 86 | +
|
| 87 | +Observing the following tables shows the above functions in operation from the database perspective: |
| 88 | +SELECT * FROM [cdr-mdr].[dbo].[DcrMessage] |
| 89 | +SELECT * FROM [cdr-mdr].[dbo].[LogEvents_DCRService] |
| 90 | +``` |
0 commit comments