Esempio n. 1
0
        private string GetDeletedSiteResourceId()
        {
            switch (ParameterSetName)
            {
            case FromDeletedResourceNameParameterSet:
                var deletedSites = WebsitesClient.GetDeletedSites().Where(ds =>
                {
                    bool match = string.Equals(ds.ResourceGroup, ResourceGroupName, StringComparison.InvariantCultureIgnoreCase) &&
                                 string.Equals(ds.Name, Name, StringComparison.InvariantCultureIgnoreCase);
                    if (!string.IsNullOrEmpty(Slot))
                    {
                        match = match && string.Equals(ds.Slot, Slot, StringComparison.InvariantCultureIgnoreCase);
                    }
                    return(match);
                });
                if (!deletedSites.Any())
                {
                    throw new Exception("Deleted app not found");
                }
                DeletedSite lastDeleted = deletedSites.OrderBy(ds => DateTime.Parse(ds.DeletedTimestamp)).Last();
                if (deletedSites.Count() > 1)
                {
                    WriteWarning("Found multiple matching deleted apps. Restoring the most recently deleted app, deleted at " + lastDeleted.DeletedTimestamp);
                }
                return("/subscriptions/" + DefaultContext.Subscription.Id + "/providers/Microsoft.Web/deletedSites/" + lastDeleted.DeletedSiteId);

            case FromDeletedAppParameterSet:
                return("/subscriptions/" + InputObject.SubscriptionId + "/providers/Microsoft.Web/deletedSites/" + InputObject.DeletedSiteId);

            default:
                throw new Exception("Parameter set error");
            }
        }
 public PSAzureDeletedWebApp(DeletedSite ds, string subscriptionId)
 {
     DeletedSiteId     = ds.DeletedSiteId.Value;
     DeletionTime      = DateTime.Parse(ds.DeletedTimestamp, System.Globalization.CultureInfo.InvariantCulture);
     SubscriptionId    = subscriptionId;
     Location          = ds.GeoRegionName;
     ResourceGroupName = ds.ResourceGroup;
     Name = ds.DeletedSiteName;
     Slot = ds.Slot;
 }
Esempio n. 3
0
        private string GetDeletedSiteResourceId()
        {
            switch (ParameterSetName)
            {
            case FromDeletedResourceNameParameterSet:
                IEnumerable <string> locations;
                if (string.IsNullOrEmpty(Location))
                {
                    locations = ResourcesClient.GetDeletedSitesLocations();
                }
                else
                {
                    locations = new List <string> {
                        Location
                    };
                }

                var deletedSites = WebsitesClient.GetDeletedSitesFromLocations(locations).Where(ds =>
                {
                    bool match = string.Equals(ds.ResourceGroup, ResourceGroupName, StringComparison.InvariantCultureIgnoreCase) &&
                                 string.Equals(ds.Name, Name, StringComparison.InvariantCultureIgnoreCase);
                    if (!string.IsNullOrEmpty(Slot))
                    {
                        match = match && string.Equals(ds.Slot, Slot, StringComparison.InvariantCultureIgnoreCase);
                    }
                    return(match);
                });
                if (!deletedSites.Any())
                {
                    throw new Exception("Deleted app not found");
                }
                DeletedSite lastDeleted = deletedSites.OrderBy(ds => DateTime.Parse(ds.DeletedTimestamp, new System.Globalization.CultureInfo("en-US"))).Last();
                if (deletedSites.Count() > 1)
                {
                    WriteWarning("Found multiple matching deleted apps. Restoring the most recently deleted app, deleted at " + lastDeleted.DeletedTimestamp);
                }
                return("/subscriptions/" + DefaultContext.Subscription.Id + "/providers/Microsoft.Web/locations/" + lastDeleted.GeoRegionName + "/deletedSites/" + lastDeleted.DeletedSiteId);

            case FromDeletedAppParameterSet:
                return("/subscriptions/" + InputObject.SubscriptionId + "/providers/Microsoft.Web/locations/" + InputObject.Location + "/deletedSites/" + InputObject.DeletedSiteId);

            default:
                throw new Exception("Parameter set error");
            }
        }