private Uri GetTemplateUri(string templateFile, string galleryTemplateName, string storageAccountName)
        {
            Uri templateFileUri;

            if (!string.IsNullOrEmpty(templateFile))
            {
                if (Uri.IsWellFormedUriString(templateFile, UriKind.Absolute))
                {
                    templateFileUri = new Uri(templateFile);
                }
                else
                {
                    storageAccountName = GetStorageAccountName(storageAccountName);
                    templateFileUri    = StorageClientWrapper.UploadFileToBlob(new BlobUploadParameters
                    {
                        StorageName      = storageAccountName,
                        FileLocalPath    = templateFile,
                        OverrideIfExists = true,
                        ContainerPublic  = false,
                        ContainerName    = DeploymentTemplateStorageContainerName
                    });
                    WriteVerbose(string.Format(
                                     "Uploading template '{0}' to {1}.",
                                     Path.GetFileName(templateFile), templateFileUri));
                }
            }
            else
            {
                templateFileUri = new Uri(GalleryTemplatesClient.GetGalleryTemplateFile(galleryTemplateName));
            }

            return(templateFileUri);
        }
Example #2
0
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="authorizationManagementClient">The management client instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     GalleryTemplatesClient galleryTemplatesClient,
     IAuthorizationManagementClient authorizationManagementClient)
 {
     GalleryTemplatesClient        = galleryTemplatesClient;
     AuthorizationManagementClient = authorizationManagementClient;
     this.ResourceManagementClient = resourceManagementClient;
 }
Example #3
0
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="authorizationManagementClient">The management client instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     GalleryTemplatesClient galleryTemplatesClient,
     IAuthorizationManagementClient authorizationManagementClient)
 {
     GalleryTemplatesClient = galleryTemplatesClient;
     AuthorizationManagementClient = authorizationManagementClient;
     this.ResourceManagementClient = resourceManagementClient;
 }
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="eventsClient">The IEventsClient instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     GalleryTemplatesClient galleryTemplatesClient,
     IEventsClient eventsClient,
     IAuthorizationManagementClient authorizationManagementClient)
 {
     ResourceManagementClient = resourceManagementClient;
     GalleryTemplatesClient = galleryTemplatesClient;
     EventsClient = eventsClient;
     AuthorizationManagementClient = authorizationManagementClient;
 }
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="storageClientWrapper">The IStorageClientWrapper instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="eventsClient">The IEventsClient instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     IStorageClientWrapper storageClientWrapper,
     GalleryTemplatesClient galleryTemplatesClient,
     IEventsClient eventsClient)
 {
     ResourceManagementClient = resourceManagementClient;
     StorageClientWrapper = storageClientWrapper;
     GalleryTemplatesClient = galleryTemplatesClient;
     EventsClient = eventsClient;
 }
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="storageClientWrapper">The IStorageClientWrapper instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="eventsClient">The IEventsClient instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     IStorageClientWrapper storageClientWrapper,
     GalleryTemplatesClient galleryTemplatesClient,
     IEventsClient eventsClient)
 {
     ResourceManagementClient = resourceManagementClient;
     StorageClientWrapper     = storageClientWrapper;
     GalleryTemplatesClient   = galleryTemplatesClient;
     EventsClient             = eventsClient;
 }
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="eventsClient">The IEventsClient instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     GalleryTemplatesClient galleryTemplatesClient,
     IEventsClient eventsClient,
     IAuthorizationManagementClient authorizationManagementClient)
 {
     ResourceManagementClient      = resourceManagementClient;
     GalleryTemplatesClient        = galleryTemplatesClient;
     EventsClient                  = eventsClient;
     AuthorizationManagementClient = authorizationManagementClient;
 }
Example #8
0
 /// <summary>
 /// Creates new ResourcesClient instance
 /// </summary>
 /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
 /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
 /// <param name="authorizationManagementClient">The management client instance</param>
 public ResourcesClient(
     IResourceManagementClient resourceManagementClient,
     GalleryTemplatesClient galleryTemplatesClient,
     // TODO: http://vstfrd:8080/Azure/RD/_workitems#_a=edit&id=3247094
     //IEventsClient eventsClient,
     IAuthorizationManagementClient authorizationManagementClient)
 {
     GalleryTemplatesClient = galleryTemplatesClient;
     // TODO: http://vstfrd:8080/Azure/RD/_workitems#_a=edit&id=3247094
     //EventsClient = eventsClient;
     AuthorizationManagementClient = authorizationManagementClient;
     this.ResourceManagementClient = resourceManagementClient;
 }
        /// <summary>
        /// Creates new ResourcesClient instance
        /// </summary>
        /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
        /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
        /// <param name="authorizationManagementClient">The management client instance</param>
        public ResourcesClient(
            IResourceManagementClient resourceManagementClient,
#if !NETSTANDARD
            GalleryTemplatesClient galleryTemplatesClient,
#endif
            IAuthorizationManagementClient authorizationManagementClient)
        {
#if !NETSTANDARD
            GalleryTemplatesClient = galleryTemplatesClient;
#endif
            AuthorizationManagementClient = authorizationManagementClient;
            this.ResourceManagementClient = resourceManagementClient;
        }
        /// <summary>
        /// Creates new ResourcesClient instance
        /// </summary>
        /// <param name="resourceManagementClient">The IResourceManagementClient instance</param>
        /// <param name="galleryTemplatesClient">The IGalleryClient instance</param>
        /// <param name="eventsClient">The IEventsClient instance</param>
        public ResourcesClient(
            IResourceManagementClient resourceManagementClient,
            GalleryTemplatesClient galleryTemplatesClient,
            // TODO: http://vstfrd:8080/Azure/RD/_workitems#_a=edit&id=3247094
            //IEventsClient eventsClient,
            IAuthorizationManagementClient authorizationManagementClient)
        {
            ResourceManagementClient = resourceManagementClient;
            GalleryTemplatesClient = galleryTemplatesClient;

            // TODO: http://vstfrd:8080/Azure/RD/_workitems#_a=edit&id=3247094
            //EventsClient = eventsClient;
            AuthorizationManagementClient = authorizationManagementClient;
        }
Example #11
0
        private Deployment CreateBasicDeployment(ValidatePSResourceGroupDeploymentParameters parameters, DeploymentMode deploymentMode)
        {
            Deployment deployment = new Deployment
            {
                Properties = new DeploymentProperties {
                    Mode = deploymentMode
                }
            };

            if (Uri.IsWellFormedUriString(parameters.TemplateFile, UriKind.Absolute))
            {
                deployment.Properties.TemplateLink = new TemplateLink
                {
                    Uri = new Uri(parameters.TemplateFile)
                };
            }
            else if (!string.IsNullOrEmpty(parameters.GalleryTemplateIdentity))
            {
                deployment.Properties.TemplateLink = new TemplateLink
                {
                    Uri = new Uri(GalleryTemplatesClient.GetGalleryTemplateFile(parameters.GalleryTemplateIdentity))
                };
            }
            else
            {
                deployment.Properties.Template = FileUtilities.DataStore.ReadFileAsText(parameters.TemplateFile);
            }

            if (Uri.IsWellFormedUriString(parameters.ParameterUri, UriKind.Absolute))
            {
                deployment.Properties.ParametersLink = new ParametersLink
                {
                    Uri = new Uri(parameters.ParameterUri)
                };
            }
            else
            {
                deployment.Properties.Parameters = GetDeploymentParameters(parameters.TemplateParameterObject);
            }

            return(deployment);
        }
Example #12
0
        private string GetTemplate(string templateFile, string galleryTemplateName)
        {
            string template;

            if (!string.IsNullOrEmpty(templateFile))
            {
                if (Uri.IsWellFormedUriString(templateFile, UriKind.Absolute))
                {
                    template = GeneralUtilities.DownloadFile(templateFile);
                }
                else
                {
                    template = FileUtilities.DataStore.ReadFileAsText(templateFile);
                }
            }
            else
            {
                Debug.Assert(!string.IsNullOrEmpty(galleryTemplateName));
                string templateUri = GalleryTemplatesClient.GetGalleryTemplateFile(galleryTemplateName);
                template = GeneralUtilities.DownloadFile(templateUri);
            }

            return(template);
        }
 public GalleryTemplatesClientTests()
 {
     galleryClientMock = new Mock<IGalleryClient>();
     galleryTemplatesClient = new GalleryTemplatesClient(galleryClientMock.Object);
 }