public async Task <IGenericResource> GetAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion = default(string), CancellationToken cancellationToken = default(CancellationToken))
        {
            // Correct for auto-gen'd API's treatment parent path as required even though it makes sense only for child resources
            if (string.IsNullOrEmpty(parentResourcePath))
            {
                parentResourcePath = "";
            }
            if (string.IsNullOrEmpty(apiVersion))
            {
                string resourceId = ResourceUtils.ConstructResourceId(Manager.Inner.SubscriptionId, resourceGroupName, resourceProviderNamespace, resourceType, resourceName, parentResourcePath);
                apiVersion = await GetApiVersionAsync(resourceId, Manager, cancellationToken);
            }
            var inner = await Inner.GetAsync(
                resourceGroupName,
                resourceProviderNamespace,
                parentResourcePath,
                resourceType,
                resourceName,
                apiVersion);

            GenericResourceImpl resource = new GenericResourceImpl(
                resourceName,
                inner,
                Manager)
            {
                resourceProviderNamespace = resourceProviderNamespace,
                parentResourceId          = parentResourcePath,
                resourceType = resourceType,
                apiVersion   = apiVersion
            };

            return(resource);
        }
示例#2
0
        ///GENMHASH:981FA7F7C88705FACC2675A0E796937F:791F75E9324E0F8CD9B54F2D9EF56E3D
        public FluentImplT WithNewAppServicePlan(string name)
        {
            appServicePlan = (AppServicePlanImpl)Manager.AppServicePlans.Define(name);
            string id = ResourceUtils.ConstructResourceId(Manager.SubscriptionId,
                                                          ResourceGroupName, "Microsoft.Web", "serverFarms", name, "");

            Inner.ServerFarmId = id;
            return((FluentImplT)this);
        }
示例#3
0
 public static ResourceId CreateForDisk(string subscription, string resourceGroup, string resource)
 => ResourceId.FromString(
     ResourceUtils.ConstructResourceId(
         subscription.ToLower(),
         resourceGroup.ToLower(),
         "Microsoft.Compute",
         "disks",
         resource.ToLower(),
         null));
示例#4
0
        public FluentImplT WithNewAppServicePlan(ICreatable <Microsoft.Azure.Management.AppService.Fluent.IAppServicePlan> appServicePlanCreatable)
        {
            AddCreatableDependency(appServicePlanCreatable as IResourceCreator <IHasId>);
            string id = ResourceUtils.ConstructResourceId(this.Manager.SubscriptionId,
                                                          ResourceGroupName, "Microsoft.Web", "serverFarms", appServicePlanCreatable.Name, "");

            Inner.ServerFarmId = id;
            WithOperatingSystem(((AppServicePlanImpl)appServicePlanCreatable).OperatingSystem());
            return((FluentImplT)this);
        }
示例#5
0
        public DiskImpl WithStorageAccountName(string storageAccountName)
        {
            var id = ResourceUtils.ConstructResourceId(this.Manager.SubscriptionId,
                                                       this.ResourceGroupName,
                                                       "Microsoft.Storage",
                                                       "storageAccounts",
                                                       storageAccountName,
                                                       "");

            return(this.WithStorageAccountId(id));
        }
 public static ResourceId CreateForStandaloneVm(
     string subscriptionId,
     string resourceGroupName,
     string vmName)
 => ResourceId.FromString(
     ResourceUtils.ConstructResourceId(
         subscriptionId.ToLower(),
         resourceGroupName.ToLower(),
         "Microsoft.Compute",
         "virtualMachines",
         vmName.ToLower(),
         ""));
 public static ResourceId CreateForVmssVm(
     string subscriptionId,
     string resourceGroupName,
     string vmssName,
     string instanceId)
 => ResourceId.FromString(
     ResourceUtils.ConstructResourceId(
         subscriptionId.ToLower(),
         resourceGroupName.ToLower(),
         "Microsoft.Compute",
         "virtualMachines",
         instanceId.ToLower(),
         $"virtualMachineScaleSets/{vmssName}"));
 internal string ConstructStorageAccountId(string vhdUrl)
 {
     try
     {
         return(ResourceUtils.ConstructResourceId(Manager.SubscriptionId,
                                                  ResourceGroupName,
                                                  "Microsoft.Storage",
                                                  "storageAccounts",
                                                  vhdUrl.Split('.')[0].Replace("https://", ""),
                                                  ""));
     }
     catch (Exception)
     {
         throw new ArgumentException(string.Format("%s is not valid URI of a blob to import.", vhdUrl));
     }
 }
示例#9
0
        public async override Task <IGenericResource> CreateResourceAsync(CancellationToken cancellationToken)
        {
            prepareDefaultValue();
            if (string.IsNullOrEmpty(apiVersion))
            {
                string resourceId = ResourceUtils.ConstructResourceId(Manager.Inner.SubscriptionId, ResourceGroupName, resourceProviderNamespace, resourceType, Name, parentResourceId);
                apiVersion = await GenericResourcesImpl.GetApiVersionAsync(resourceId, Manager, cancellationToken);
            }
            GenericResourceInner inner = await Manager.Inner.Resources.CreateOrUpdateAsync(ResourceGroupName,
                                                                                           resourceProviderNamespace,
                                                                                           parentResourceId,
                                                                                           resourceType,
                                                                                           Name,
                                                                                           apiVersion,
                                                                                           Inner,
                                                                                           cancellationToken);

            SetInner(inner);
            return(this);
        }
 public async Task DeleteAsync(
     string resourceGroupName,
     string resourceProviderNamespace,
     string parentResourcePath,
     string resourceType,
     string resourceName,
     string apiVersion = default(string),
     CancellationToken cancellationToken = default(CancellationToken))
 {
     if (string.IsNullOrEmpty(apiVersion))
     {
         string resourceId = ResourceUtils.ConstructResourceId(Manager.Inner.SubscriptionId, resourceGroupName, resourceProviderNamespace, resourceType, resourceName, parentResourcePath);
         apiVersion = await GetApiVersionAsync(resourceId, Manager, cancellationToken);
     }
     await Inner.DeleteAsync(
         resourceGroupName,
         resourceProviderNamespace,
         parentResourcePath,
         resourceType,
         resourceName,
         apiVersion,
         cancellationToken);
 }