コード例 #1
0
        public void ReadBlobNotExisting()
        {
            string             testaseName = "test" + DateTime.Now.ToString();
            var                asmnode     = ParseIps();
            StorageCredentials credentials = new StorageCredentials(accountName, storageKey);
            var                bpp         = new BlobPersistProvider(credentials, containerName);
            var                record      = bpp.Get(testaseName);

            Assert.IsNull(record);
        }
コード例 #2
0
        public void Persist()
        {
            string             testaseName = "test";
            var                asmnode     = ParseIps();
            StorageCredentials credentials = new StorageCredentials(accountName, storageKey);
            var                bpp         = new BlobPersistProvider(credentials, containerName);

            bpp.Save(testaseName, asmnode);
            var record = bpp.Get(testaseName);

            Assert.AreEqual(asmnode.description, record.description);
            Assert.AreEqual(asmnode.endpoints.Count, record.endpoints.Count);
            Assert.AreEqual(asmnode.ports.Count, record.ports.Count);
        }
コード例 #3
0
        public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, TraceWriter log)
        {
            // get config values
            string subscriptionId       = ConfigurationManager.AppSettings["subscriptionId"];
            string rgName               = ConfigurationManager.AppSettings["rgname"];
            string aseName              = ConfigurationManager.AppSettings["asename"];
            string tenantId             = ConfigurationManager.AppSettings["tenantId"];
            string appid                = ConfigurationManager.AppSettings["appid"];
            string appKey               = ConfigurationManager.AppSettings["appKey"];
            string accountName          = ConfigurationManager.AppSettings["accountName"];
            string storageKey           = ConfigurationManager.AppSettings["storageKey"];
            string containerName        = ConfigurationManager.AppSettings["containerName"];
            string automationWebhookUrl = ConfigurationManager.AppSettings["automationwebhookurl"];
            // Az management API provider
            var azmgmt = new AzureManagementProvider(subscriptionId, rgName, tenantId, appid, appKey);
            // Blob Storage paersistence
            var bpp = new BlobPersistProvider(new StorageCredentials(accountName, storageKey), containerName);
            // Azure Automation webhook notifier
            var webhook = new WebhookNotify(automationWebhookUrl);
            // probe ASE Management
            var agent  = new AseAgent(azmgmt, bpp, webhook);
            var result = agent.ProbeAseManagement(aseName);

            // if there are changes log it
            if (result.Count > 0)
            {
                foreach (string newip in result)
                {
                    log.Info("New ASE Mangement IP " + newip + DateTime.Now.ToString());
                }
            }
            else
            {
                log.Info($"No change ASE Mangement IPs at {DateTime.Now}");
            }
        }