Microsoft.Azure.Commands.RecoveryServices.PSRecoveryServicesClient.GetSubscriptionId C# (CSharp) Method

GetSubscriptionId() public static method

public static GetSubscriptionId ( string resourceId ) : string
resourceId string
return string
        public static string GetSubscriptionId(string resourceId)
        {
            const string subscriptions = "subscriptions";

            var startIndex = resourceId.IndexOf(subscriptions, StringComparison.OrdinalIgnoreCase) + subscriptions.Length + 1;
            var endIndex = resourceId.IndexOf("/", startIndex, StringComparison.OrdinalIgnoreCase);

            return resourceId.Substring(startIndex, endIndex - startIndex);
        }

Usage Example

Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ARSVault" /> class.
 /// </summary>
 /// <param name="vault">vault object</param>
 public ARSVault(VaultCreateResponse vault)
 {
     this.ID                           = vault.Id;
     this.Name                         = vault.Name;
     this.Type                         = vault.Type;
     this.Location                     = vault.Location;
     this.ResouceGroupName             = PSRecoveryServicesClient.GetResourceGroup(vault.Id);
     this.SubscriptionId               = PSRecoveryServicesClient.GetSubscriptionId(vault.Id);
     this.Properties                   = new ASRVaultProperties();
     this.Properties.ProvisioningState = vault.Properties.ProvisioningState;
 }
All Usage Examples Of Microsoft.Azure.Commands.RecoveryServices.PSRecoveryServicesClient::GetSubscriptionId