Monday, August 20, 2018

Connecting VSTS to Azure Subscriptions

Step 1: Manage Azure Subscriptions in Release or Build definitions


Click Manage in the Azure subscription. And it is redirected to the service connection tab. 





  
Step 2: Add a new Service Endpoint to VSTS Account

Click New Service connection to Add new connection and pop up below dialog.  If the Azure subscription you want to use is not automatically visible to VSTS, then you will have to configure the connection. This is done manually using the advanced settings. Near the bottom of the dialog, click the link in the instructions that says “use the full version of the endpoint dialog”


Pop up below dialog and we need to fill the details to configure.



Step 3: Log In to Azure Portal to get the Subscription ID and Subscription Name 

Go to the Subscriptions blade (Search Resources feature found at the top of each page in the Azure portal.) the values you need will be displayed on the screen. Copy these two values to the dialog.




Step 4: Get the Tenant ID in Azure Active Directory blade

Go to the Azure Active Directory blade. Open the Properties menu blade. Copy the Directory ID field to the Tenant ID. The Tenant ID is a reference to the Azure Active Directory (AAD) instance within the subscription.




Step 5: Get the Service Principal Client ID in Azure Active Directory blade

Go to the App Registrations menu blade and select New application registration. In the Create dialog, give the application a friendly name, such as VSTS Connection. Use the default Application Type (Web app/API). The sign-on URL must be unique but otherwise can have any value. After you have created the application, the Properties menu for the new application will show you the Application ID. Copy the value from Application ID to the Service Principal Client ID field.





Step 6: Get the Service Principal Key in Azure Active Directory blade

Click the Setting newly created application as below



Open the Keys menu in your newly created application. In the empty field, type a descriptive name for the key you are wanting to create. Set the expiration time for an appropriate amount of time. Press Save to commit your changes. The application’s key is displayed. Copy this value to Service Principal Key.



Step 6:  Giving the application permissions on Azure in the Subscription blade. 

Go to the Subscription blade and select the targeted subscription. Within that blade, open the Access control (IAM) menu. Click Add to grant our application permission. Choose the Contributor role. Under select, type the name of the application that you created. Once it appears, click the application to mark it as selected. Then, press Save to confirm your changes and confirm the updated permissions.





Step 7:  Return to VSTS and test your connection.

At this point, the Service Endpoint should verify and show as able to connect. refresh the subscription drop down. You will see your Azure subscription is now available.







Tuesday, July 23, 2013

Insert a image into database by using FileUpload in ASP.net

Create a table as tblImages


First open a new project and select ASP.net Web Application and rename it as UploadImage


Then add a class file

And rename it as ConnectToDB. we are going to write the source code for database connection.
you must import "using System.Data.SqlClient;"

When you assign data source to connection string. you have to add a new Data Connection.
so first you select Sever Explore and do as below


After you clicking Continue button, you will be able to see this window
Then you select your sever name and database name. then you click Advance button and you will get this window

then copy the Data Source which is highlighted. then click Ok

then you will be able to see this window and click on Test Connection
then finish this by clicking Ok buttons. then you go and pate your Data Source that you have copied before into connection string as below

 m_ConnectingString = "Data Source=UDARA-PC;Initial Catalog=random;Integrated Security=True";

Now you have finished writing your source code for ConnectToDB class.                                                     
Then add a class as DataHandler and here is the source code for it

Now you add FileUpload, Button as txt_upload and two labels which are lbl_details and lbl_status into Default.aspx
   
Add a folder as Images

then right click and click view code and write source codes as below
then call the ImageUpload method in the btn_upload button click event as below

 Then starting Debugging 

 After clicking upload button, and your image uploading is successful, you will be able to see like this


Then you check your Images folder in your project, you can see the photo you have uploaded

Again add the two textboxes and two labels and design like this


Declare a variable as strSQL for the query and create an instance of DataHandler class


  let's write the source code for inserting image into the table

after debugging and it is successful, you will be able to see like this
Then check your table and you can see the data has added into table



Next time i will tell you how to retrieve the images from database by using GridView  in this project

To be Continued  

Connecting VSTS to Azure Subscriptions

Step 1: Manage Azure Subscriptions in Release or Build definitions Click Manage in the Azure subscription. And it is redirected to th...